JavaScript Basic Flashcards
What is JavaScript
a scripting or programming language that allows you to implement complex features on web page
Java vs JavaScript
Java code must be compiled, and JavaScript code is interpreted directly by a borwser
JavaScript code is run on a browser only, while Java creates applications that run in a virtual machine or browser.
Java is an OOP (object-oriented programming) language, and JavaScript is specifically an OOP scripting language.
Java Multithreaded, JavaScript is single threaded
Java is static type and JavaScript is dynamic type
Advantage of JavaScript
Client side no need for server
Dynamically typed
JavaScript Datatypes
Number String Boolean Object Undefined
== and ===
double compares value, triples compare datatype then value
XML
extensible markup language, rule for encoding documents in format that is human- readable and machine readable
Var
function scope
Let
Block scope
Const
block scope, only primitive is constant, can’t be changed once assigned. Need to be assigned when declared
Falsy Value
undefined, null,0 , false , NaN, ‘ ‘
Undefined
uninitialized variable
Synchronous
same waiter serve multiple table but waits for chef to finish before server another
Asynchronous Single threaded non-blocking
same waiter serving multiple table
Closures
Closure is a locally declared variable related to a function which stays in memory when the function has returned. (e.g nested function)
Promises
pending(initial state), fulfilled(operation success), rejected (operation failed), lets asynchronous method return values like synchronous method, instead of immediately returning the final value, it returns promise that it’ll supply the value in the future