שלום אורח התחבר

אורך הפרק כ-10 דקות

 

הקוד זמין גם באתר jsbin בקישור:

http://jsbin.com/bugeso/1/edit?js,output

syntax.js

// JavaScript Syntax
/*
 * 1. Comments
 * 2. Variables
 * 3. Data Types + Operators
 * 4. Loops and Conditionals
 * 5. functions and scope
 */

function test() {
	console.log('Hello World');
}

// In JavaScript - main is just a regular function name
// we use it as a convention to name our "main" function
// but can also use any other name we choose.
function main() {
	var foo = 10;
	var name = 'ynon';
	var f = test;
	
	var myfunction = function() {
		console.log("code is not yet executed");	
	};
	
	f();
	
	var z = 10 + 20;
	var x = 10 * 7;

	// email = ynon@gmail.com
	var email = name + '@gmail.com';
	
	for(var i=0;i<10; i++) {
		console.log('i = '  +i);
	}
	
	while(name.indexOf('n') > -1) {
		name = name.substr(1);	
	}
	
	x = 10;
	z = '10';
	
	if (x==z) {
		// statement is true
	}
	
	if (x===z) {
		// not executed - false
	}
	
	if(Number(x) === Number(z)) {
		// true	
	}
	
	

}








syntax.html

<!DOCTYPE html
<html>

	<head>
		<meta charset="utf-8" />
		<title>JS Syntax</title>
	</head>
	<body>
		<script src="syntax.js" ></script>
	</body>

</html>