PROJECTENGRAM

JAVASCRIPT BASIC SYNTAX

JavaScript Basic Syntax

Tags: #◇Web Development #◇CCAPDEV #◇JavaScript Basic Syntax #◇Code Snippets #◇M3


◇Overview

Extracted notes for JavaScript Basic Syntax covering both theoretical and practical elements.

◇Key Definitions

Data Types JavaScript supports the following primitive data types: Numbers – such as 125, 12.9, etc. Strings – text such as “Hello World” Boolean – true or false
Variables JavaScript is an untyped language – a variable can be of any data type. The data type of a variable can change based on the data type of the value assigned to it.

◇Code Implementation

『』
TEXT
Variables
<script>
	var id;
	var name;
</script>
『』
TEXT
Variables
<script>
	var id, name;
</script>
『』
TEXT
Variables
<script>
	var id = 113;
	var name;
	name = “Ned”
</script>
『』
TEXT
Variables
Global Scope – variables defined anywhere in the JavaScript code. These variables are accessible to all functions that have no duplicate identifier names.
Function Scope – variables declared within a function. These variables are only visible within its function.
Block Scope – variables declared within a block (i.e., { }). These variables are only visible within its block. New feature as of ES6 (2015) & onwards. 
『』
TEXT
Variables... example
<script>
	var myVar = "global"; // global scope
	function sample() {
		var myVar = "func"; //function scope
		document.write(myVar);
		if (myVar == "func")
		{
			let myVar = "block"; // block scope
			document.write("block" + myVar);
			var myVar2 = "func"; // STILL function scope		}
	}
</script>

◇Syntax Breakdown

Ensure correct syntax for JavaScript Basic Syntax Pay attention to specific functions and declarations.

◇Complexity Analysis

Time Complexity: O(1) for typical operations unless looping. Space Complexity: O(1) generally.

◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

Which of the following variable scopes was introduced in ES6 (2015) and is limited to variables declared within { }?

Q2

Because JavaScript is an untyped language, which of the following statements is true?

Q3

Which of the following correctly describes "Function Scope" in JavaScript?

JavaScript Basic Syntax | PROJECT ENGRAM