Skip to content

Latest commit

 

History

History
212 lines (152 loc) · 11.3 KB

README.md

File metadata and controls

212 lines (152 loc) · 11.3 KB

JAVASCRIPT FUNDAMENTALS

Searching for JavaScript:

W3Schools: => Google for: w3schools js alert, w3schools js String, etc.

MDN JS: => Google for: mdn js alert, mdn js String, etc.

JavaScript Day 01

What can you build with JavaScript?

CODE

QUESTIONS

How do we clear the console?

  • Click the Clear Console Button
  • Press Ctrl + L
  • Write console.clear();

How do we change the default browser used by the Live Server VSCode extension?

  • Go to File > Preferences > Settings and search for Live Server custom browser
  • In the Live Server: Custom Browser setting select your favorite Browser
  • Note: Settings are saved automatically
  • Note: On Mac you can access the Settings from: Code > Preferences > Settings
JavaScript Day 02

CODE

QUESTIONS

What happens if I omit the ; after a statement? Is it optional?

  • If you omit a semicolon ; at the end of the statement, JavaScript will try to guess and automatically place the semicolon itself. Most of the times, it does a good job at this, but there are cases where the automatic semicolon placement mechanism will produce undesirable effects. Therefore, we tend to place the semicolons ourselves. Try to get into the habit of placing semicolons at the end of your statements.

Does the semicolons at the end of JavaScript statements work much like the ones in CSS?

  • In a way, they do. Just like we must end each CSS rule with a semicolon; we also have to end each JS statement with a semicolon too, but, unlike CSS, JavaScript can deal with omitted semicolons by placing them automatically. So, most of the time, our statements will work without semicolons at the end, whereas in CSS an omitted semicolon will break subsequent CSS rules.

Are the break and default statements optional inside the switch statement?

When we do a string comparison with ==, e.g. "4" == 3, which operand gets converted?

  • The String part is converted to a Number, e.g. "4" becomes 4 and then it's value is compared with 3
    (Reference: Comparing Strings to Numbers)

How does the switch statement compares the switch value with each case value?

Example:

switch (a) {
	case 2:
		// do something
		break;
	case 42:
		// do another thing
		break;
	default:
		// fallback to here
}
  • "...the matching that occurs between the a expression and each case expression is identical to the === algorithm." Reference:

  • How do we print newlines to the console?

Using the '\n' escape character.

console.log("A line and \n another line and yet \n another line!");

  • When should we place the <script> tags in the <head> area?

    • When you insert a library script such as the jQuery library
    • When performance/page load times are not considerably affected by the script
    • When you want to tweak CSS styling before the body is rendered via a script.

VISUALIZATIONS

REFERENCES

JavaScript Day 03

CODE

  • Array Loops

  • Functions

  • Quick Array Reference:

    	`let months = [ 1, 2, 3 ];`<br/>
    	`months.push( 4, 5, 6 ); 	// [ 1, 2, 3, `**`4, 5, 6`**` ]`<br/>
    	`months.pop();      		// [ 1, 2, 3, 4, 5 ]`<br/>
    	`months.shift();    		// [ 2, 3, 4, 5 ]`<br/>
    	`months.unshift( 0, 1 ); 	// [ `**`0, 1`**`, 2, 3, 4, 5]`<br/>
    	`months[0]; 				// 0`<br/>
    	`months[1]; 				// 1`<br/>
    
    	**NESTED ARRAYS:** Arrays inside Arrays and how to access them
    	```
    	let nested = [
    1,
    2,
    3,
    [ "Corto", "Maltese" ]
    

    ];

    `nested[0]; // 1`<br/>
    `nested[1]; // 2`<br/>
    `nested[2]; // 3`<br/>
    `nested[3]; // [ "Corto", "Maltese" ]`<br/>
    `nested[3][0]; // "Corto"`<br/>
    `nested[3][1]; // "Maltese"`<br/>
    
    

QUESTIONS

Can we manually break out of an Infinite Loop?

REFERENCES

RESOURCES | TOOLS

RESOURCES | LEARNING