You Don't Know Js

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

executed

"How do those collections of programming statements tell the computer what to do? The program needs to be _______, also referred to as running the program."

compiles

"It's typically asserted that JavaScript is interpreted, because your JavaScript source code is processed each time it's run. But that's not entirely accurate. The JavaScript engine actually _________ the program on the fly and then immediately runs the compiled code."

semicolon

"Most statements in JavaScript conclude with a ____________ (;) at the end."

right-hand

"The = equals operator is used for assignment -- we first calculate the value on the______________ side (source value) of the = and then put it into the variable that we specify on the left-hand side (target variable)."

function

A ____________ is generally a named section of code that can be "called" by name, and the code inside it will be run each time.

expression

A function value should be thought of as an __________, much like any other value or ___________.

compiled

Any snippet of JavaScript has to be __________ before (usually right before!) it's executed.

arguments

Functions can optionally take ________ (aka parameters) -- values you pass in. And they can also optionally return a value back.

first class

Functions in JS are said to be "__________" in that they are basically just normal objects (with callable behavior semantics bolted on), and so they can be handled like any other plain object.

non-JavaScript

The most common _________ JavaScript you'll encounter is the DOM API. For example:

do..while

The only practical difference between a while and do..while loop is whether the conditional is tested before the first iteration (while) or after the first iteration (________).

false

When this non-boolean value is coerced to a boolean, does it become true or false? (false)

Lexical scope

_____________ means that scope is defined by author-time(when writing the code) decisions of where functions are declared.

transpiling

a tool that converts your newer code into older code equivalents. This process is commonly called "__________," a term for transforming + compiling.

conditionals

aka decisions

new binding

new is the final way that a function call's this can be bound. We'll call this ___________. (By calling foo(..) with new in front of it, we've constructed a new object and set that new object as the this for the call of foo(..))

expression statement

"A general expression that stands alone is also called an ______________________, such as the following:"

call expression

"A more common expression statement is a ____________ statement (see "Functions"), as the entire statement is the function call expression itself:"

source code

"A program, often referred to as _________ or just code, is a set of special instructions to tell the computer what tasks to perform."

expression

"An ________________ is any reference to a variable or value, or a set of variable(s) and value(s) combined with operators."

why

"Comments should explain _____, not what. They can optionally explain how if that's particularly confusing."

statement

"In a computer language, a group of words, numbers, and operators that performs a specific task is a _________."

expressions

"Statements are made up of one or more _______________."

operators

"The = and * characters are __________ -- they perform actions with the values and variables such as assignment and mathematic multiplication."

assignment

"The = equals operator is used for _______________ -- we first calculate the value on the right-hand side (source value) of the = and then put it into the variable that we specify on the left-hand side (target variable)."

variables

"The characters a and b are called ________ , which are like simple boxes you can store any of your stuff in."

syntax

"The rules for valid format and combinations of instructions is called a computer language, sometimes referred to as its ______, much the same as English tells you how to spell words and how to create valid sentences using words and punctuation."

literal value

"This statement has four expressions in it: 2 is a ___________________ expression b is a variable expression, which means to retrieve its current value b * 2 is an arithmetic expression, which means to do the multiplication a = b * 2 is an assignment expression, which means to assign the result of the b * 2 expression to the variable a"

variable

"This statement has four expressions in it: 2 is a literal value expression b is a _____________ expression, which means to retrieve its current value b * 2 is an arithmetic expression, which means to do the multiplication a = b * 2 is an assignment expression, which means to assign the result of the b * 2 expression to the variable a"

arithmetic

"This statement has four expressions in it: 2 is a literal value expression b is a variable expression, which means to retrieve its current value b * 2 is an _____________ expression, which means to do the multiplication a = b * 2 is an assignment expression, which means to assign the result of the b * 2 expression to the variable a"

assignment

"This statement has four expressions in it: 2 is a literal value expression b is a variable expression, which means to retrieve its current value b * 2 is an arithmetic expression, which means to do the multiplication a = b * 2 is an ____________ expression, which means to assign the result of the b * 2 expression to the variable a"

explicit coercion

"Using Number(..) (a built-in function) as shown is an ___________________ from any other type to the number type."

literals

"Values that are included directly in the source code are called ________."

Programs

"____________ are just collections of many such statements, which together describe all the steps that it takes to perform your program's purpose."

operators

"_____________ are how we perform actions on variables and values."

interpreter

"a special utility on the computer (either an ______________ or a compiler) is used to translate the code you write into commands a computer can understand."

types

"different representations for values are called ______ in programming terminology."

literal value

"the 2 is just a value itself, called a __________, because it stands alone without being stored in a variable."

compiling

"translation done ahead of time, called _____________ the code, so when the program runs later, what's running is actually the already compiled computer instructions ready to go."

interpreting

"translation of commands done from top to bottom, line by line, every time the program is run, is usually called ___________ the code."

callable object

'function' is a sub-type of object (technically, a "________________")

call-site

'this' is a binding made for each function invocation, based entirely on its _________ (how the function is called).

singleton

A slight variation on the module pattern is when you only care to have one instance, a "__________." Note the IIFE

functions

A subtle detail (that can show up in code with multiple "duplicate" declarations) is that ________ are hoisted first, and then variables.

variable

A symbolic container, so called because the value in this container can vary over time as needed, needed to track a value as it changes over the course of the program.

optimizable

Adhering to strict mode makes your code generally more __________ by the engine.

declarations

All __________________, both variables and functions, are processed first, before any part of your code is executed.

array

An _____ is an object that holds values (of any type) not particularly in named properties/keys, but rather in numerically indexed positions.

start

An identifier must ______ with a-z, A-Z, $, or _.

Collision Avoidance

Another benefit of "hiding" variables and functions inside a scope avoids unintended collision between two different identifiers with the same name but different intended usages.

ternary operator

Another form of conditional in JavaScript is the "conditional operator," often called the "___________." It's like a more concise form of a single if..else statement, such as:

immediately invoked function expression (IIFE)

Another way to execute a function expression, which is typically referred to as an ________________________:

subtypes

Array and function are NOT proper built-in types, these should be thought of more like ________ -- specialized versions of the object type.

extra behavior

Arrays are also a form of objects, with ________________. The organization of contents in arrays is slightly more structured than for general objects.

numeric indexing

Arrays assume _____________, which means that values are stored in locations, usually called indices, at non-negative integers/

(function or global) scope

Arrow-functions adopt the this binding from the enclosing ______________________.

IIFE

Because an ____ is just a function, and functions create variable scope, using an ____ in this fashion is often used to declare variables that won't affect the surrounding code outside the ____:

properties

Because arrays are special objects (as typeof implies), they can also have _____________, including the automatically updated length property.

explicit binding

Both call(..) and apply(..) take, as their first parameter, an object to use for the 'this', and then invoke the function with that 'this' specified. What type of binding is this?

keys

Bracket notation is useful if you have a property name that has special characters in it, like obj["hello world!"] -- such properties are often referred to as ________ when accessed via bracket notation.

let

But it's ES6's introduction of _____ that finally gives full, unfettered block-scoping capability to our code.

constant

By combining writable:false and configurable:false, you can essentially create a __________ (cannot be changed, redefined or deleted) as an object property.

recursion

Calling a function from inside itself

compiled

Despite the fact that JavaScript falls under the general category of "dynamic" or "interpreted" languages, it is in fact a _______ language.

strict mode

ES5 added a "_________________" to the language, which tightens the rules for certain behaviors. Generally, these restrictions are seen as keeping the code to a safer and more appropriate set of guidelines.

let

ES6 ____s you declare variables to belong to individual blocks (pairs of { .. }), using the ____ keyword.

computed property names

ES6 adds ________________, where you can specify an expression, surrounded by a [ ] pair, in the key-name position of an object-literal declaration

default parameter values

ES6 adds a feature called "________." It looks like this:

arrow function

ES6 adds a special syntactic form of function declaration called the "__________"

iteration

Each time the loop block executes, that's called an ___________.

global object

Global variables are also automatically properties of the _______ (window in browsers, etc.), so it is possible to reference a global variable not directly by its lexical name, but instead indirectly as a property reference of the __________.

console.log(this);

Hint: to know what "This" points to, simply use _______ before using it to log to the console the object it becomes.

this

If a function has a ____ reference inside it, that ____ reference usually points to an object. But which object it points to depends on how the function was called.

lexing

If the tokenizer were to invoke stateful parsing rules to figure out whether 'a' should be considered a distinct token or just part of another token, that would be ______.

ReferenceError

If you try to access a variable's value in a scope where it's not available, you'll get a __________ thrown. For example:

coercion

In JavaScript conversion between types is called ___________.

scope

In JavaScript, each function gets its own ______ (technically called lexical scope). _______ is basically a collection of variables as well as the rules for how those variables are accessed by name.

identifiers

In JavaScript, variable names (including function names) must be valid __________.

const

In addition to let, ES6 introduces _______, which also creates a block-scoped variable, but whose value is fixed (constant). Any attempt to change that value at a later time results in an error.

block

In code we often need to group a series of statements together, which we often call a ________.

property

In regard to accessing objects, the '.a' syntax is usually referred to as "___________" access

key

In regard to accessing objects, the ["a"] syntax is usually referred to as "________" access.

type enforcement

In some programming languages, you declare a variable (container) to hold a specific type of value, such as number or string. This is known as Static typing, otherwise known as ________________.

literal object form

It is strongly preferred by the majority of the JS community to use the ___________ for a value, where possible, rather than the constructed object form.

complex primitives

It's a common mis-statement that "everything in JavaScript is an object". This is clearly not true. By contrast, there are a few special object sub-types, which we can refer to as _______________.

catch

It's a very little known fact that JavaScript in ES3 specified the variable declaration in the _____ clause of a try/catch to be block-scoped to the ______ block. For instance:

per-scope

It's also important to note that hoisting is ______________.

does not

It's important to realize that this ____ refer to the function itself, as is the most common misconception.

hoisted function declarations

It's more common and accepted to use ________________, as we do with the foo() call appearing before its formal declaration.

dynamic scope

JavaScript does not, in fact, have _____________. Rather, it has a close cousin called 'this'

typeof

JavaScript provides a ______ operator that can examine a value and tell you what type it is:

dynamic typing

JavaScript uses _____________, meaning variables can hold values of any type without any type enforcement.

namespace

Libraries typically will create a single variable declaration, often an object, with a sufficiently unique name, in the global scope. This object is then used as a "__________" for that library, where all specific exposures of functionality are made as properties off that object (____________), rather than as top-level lexically scoped identifiers themselves.

2

Many developers would expect undefined, since the var a statement comes after the a = 2, and it would seem natural to assume that the variable is re-defined, and thus assigned the default undefined. However, the output will be _____.

hoisting

Metaphorically, this behavior is called ________, when a var declaration is conceptually "moved" to the top of its enclosing scope. Technically, this process is more accurately explained by how code is compiled

invoked

Modules require two key characteristics: 1) an outer wrapping function being _________, to create the enclosing scope 2) the return value of the wrapping function must include reference to at least one inner function that then has closure over the private inner scope of the wrapper.

reference

Modules require two key characteristics: 1) an outer wrapping function being invoked, to create the enclosing scope 2) the return value of the wrapping function must include ___________ to at least one inner function that then has closure over the private inner scope of the wrapper.

object property access

Name this operator: " ."

loose not-equals

Name this operator: "!="

strict not-equals

Name this operator: "!=="

and

Name this operator: "&&"

multiplication

Name this operator: "*"

addition

Name this operator: "+"

increment

Name this operator: "++"

compound assignment

Name this operator: "+=, -=, *=, and /="

subtraction

Name this operator: "-"

decrement

Name this operator: "--"

division

Name this operator: "/"

less than

Name this operator: "<"

less than or loose-equals

Name this operator: "<="

assignment

Name this operator: "="

loose-equals

Name this operator: "=="

strict-equals

Name this operator: "==="

greater than

Name this operator: ">"

greater than or loose-equals

Name this operator: ">="

or

Name this operator: "||"

this

No such bridge is possible. You cannot use a ______ reference to look something up in a lexical scope. It is not possible.

arrow-function

Normal functions abide by the 4 rules of 'this'. But ES6 introduces a special kind of function that does not use these rules: _____________.

dot notation

Object Properties can either be accessed with ________ (i.e., obj.a) or bracket notation (i.e., obj["a"]).

bracket notation

Object Properties can either be accessed with dot notation (i.e., obj.a) or __________ (i.e., obj["a"]).

naming

Of course, IIFE's don't need names, necessarily -- the most common form of IIFE is to use an anonymous function expression. While certainly less common, _____________ an IIFE benefits over anonymous function expressions, so it's a good practice to adopt.

auto-global

One key difference (improvement!) with strict mode is disallowing the implicit ____________ variable declaration from omitting the var:

developer

One of the most important lessons you can learn about writing code is that it's not just for the computer. Code is every bit as much, if not more, for the ____________ as it is for the compiler.

"AST" (Abstract Syntax Tree)

Parsing a stream (array) of tokens and turning it into a _______ of nested elements, which collectively represent the grammatical structure of the program. (The tree for 'var a = 2;' might start with a top-level node called 'VariableDeclaration', with a child node called 'Identifier' (whose value is 'a'), and another child called 'AssignmentExpression' which itself has a child called 'NumericLiteral' (whose value is 2))

==

Regarding equality, ______ checks for value equality with coercion allowed.

===

Regarding equality, ______ checks for value equality without allowing coercion.

loops

Repeating a set of actions until a certain condition fails -- in other words, repeating only while the condition holds -- these are known as _________.

new (new binding)

Rule 1: Is the function called with ___________? If so, this is the newly constructed object.

call or apply (explicit binding)

Rule 2: Is the function called with _____________________, even hidden inside a bind hard binding? If so, this is the explicitly specified object.

context (implicit binding)

Rule 3: Is the function called with a __________________, otherwise known as an owning or containing object? If so, this is that context object.

this (default binding)

Rule 4: Otherwise, default the ______________. If in strict mode, pick undefined, otherwise pick the global object.

Default Binding

Since the call site of getA is in global scope, getA() will be bound to global object. ('this' points to the global object) This is know as ____________.

switch statement

Sometimes you may find yourself writing a series of if..else..if statements. This structure works, but it's a little verbose because you need to specify the a test for each case. Here's another option, the ______________

after

Still another variation of the IIFE inverts the order of things, where the function to execute is given second, ____________ the invocation and parameters to pass to it. (This pattern is used in the UMD (Universal Module Definition) project.)

relational comparison

The <, >, <=, and >= operators are used for inequality, referred to in the specification as "_____________."

lexical this

The ES6 solution to the loss of this in the arrow-function, introduces a behavior called "__________".

let

The ____ keyword attaches the variable declaration to the scope of whatever block (commonly a { .. } pair) it's contained in. In other words, _____ implicitly hijacks any block's scope for its variable declaration.

object

The ______ type refers to a compound value where you can set properties (named locations) that each hold their own values of any type. (This is perhaps one of the most useful value types in all of JavaScript)

eval(..)

The _______ function in JavaScript takes a string as an argument, and treats the contents of the string as if it had actually been authored code at that point in the program.

document

The ________ variable exists as a global variable when your code is running in a browser. It's a special object, often called a "host object."

if statement

The ___________ requires an expression in between the parentheses ( ) that can be treated as either true or false.

writable

The ability for you to change the value of a property is controlled by __________.

"invalid number value" NaN

The biggest gotcha you may run into here with comparisons between potentially different value types. How can all three of those comparisons be false? Because the b value is being coerced to the ______________ in the < and > comparisons.

scope closure

The contents inside the module file are treated as if enclosed in a _______________, just like with the function-closure modules

host object

The document variable exists as a global variable when your code is running in a browser. It's a special object, often called a "__________."

this

The first common temptation is to assume _______ refers to the function itself. (Why would you want to refer to a function from inside itself? The most common reasons would be things like recursion (calling a function from inside itself) or having an event handler that can unbind itself when it's first called.)

anonymous

The first function expression assigned to the foo variable is called ___________ because it has no name.

initialization clause

The for loop has three clauses: the ________________ (var i=0), the conditional test clause (i <= 9), and the update clause (i = i + 1).

conditional test clause

The for loop has three clauses: the initialization clause (var i=0), the ___________________ (i <= 9), and the update clause (i = i + 1).

update clause

The for loop has three clauses: the initialization clause (var i=0), the conditional test clause (i <= 9), and the ________________ (i = i + 1).

module

The most common usage of closure in JavaScript is the _______ pattern.

hard binding

The most typical way to wrap a function with a ____________ creates a pass-thru of any arguments passed and any return value received

constants

The newest version of JavaScript at the time of this writing (commonly called "ES6") includes a new way to declare ____________

while

The only practical difference between a while and do..while loop is whether the conditional is tested before the first iteration (________) or after the first iteration (do..while).

string values

The return value from the typeof operator is always one of six (seven as of ES6! - the "symbol" type) ___________. That is, typeof "abc" returns "string", not string.

named

The second function expression is ____________ (bar), even as a reference to it is also assigned to the x variable.

call-stack

The stack of functions that have been called to get us to the current moment in execution

dynamically generating code

The use-cases for _________________ inside your program are incredibly rare, as the performance degradations are almost never worth the capability.

polyfill

The word "________" is an invented term used to refer to taking the definition of a newer feature and producing a piece of code that's equivalent to the behavior, but is able to run in older JS environments.

reserved words

These words are called "____________," and include the JS keywords (for, in, if, etc.) as well as null, true, and false.

Principle of Least Privilege

This design principle states that in the design of software, such as the API for a module/object, you should expose only what is minimally necessary, and "hide" everything else.

anonymous function expression

This is called an "________________", because function()... has no name identifier on it.

let block

This is called the "__________" or "let statement" (Instead of implicitly hijacking an existing block, the let-statement creates an explicit block for its scope binding.)

switch

This is the ______ statement.

Revealing Module

This is the pattern in JavaScript we call module. The most common way of implementing the module pattern is often called "______________"

variable

Though it may not seem obvious from that syntax, foo is basically just a _______ in the outer enclosing scope that's given a reference to the function being declared.

lexical scope

To be clear, this does not, in any way, refer to a function's _________.

state

Tracking the changes to values as your program runs.

compiler, engine

Two distinct actions are taken for a variable assignment: First, _____________ declares a variable (if not previously declared in the current scope), and second, when executing, _________ looks up the variable in Scope and assigns to it, if found.

variable hoisting

Warning: It's not common or a good idea to rely on _________ to use a variable earlier in its scope than its var declaration appears; it can be quite confusing.

argument

We can pass in ______________(s) to an IIFE. For example, the window object reference, but we name the parameter global, so that we have a clear stylistic delineation for global vs. non-global references.

break

We can use JavaScript's ________ statement to stop a loop. Also, we can observe that it's awfully easy to create a loop that would otherwise run forever without a ________ing mechanism.

dynamic

Weak typing, otherwise known as ____________ typing, allows a variable to hold any type of value at any time.

constructed object

What form of object is this:

declarative (literal) object

What form of object is this:

implicit binding

When there is a context object for a function reference, the ___________ rule says that it's that object which should be used for the function call's this binding.

false

When this non-boolean value is coerced to a boolean, does it become true or false? ("" (empty string))

false

When this non-boolean value is coerced to a boolean, does it become true or false? ("0, -0, NaN (invalid number))

true

When this non-boolean value is coerced to a boolean, does it become true or false? ("[ ], [ 1, "2", 3 ] (arrays))

true

When this non-boolean value is coerced to a boolean, does it become true or false? ("hello")

true

When this non-boolean value is coerced to a boolean, does it become true or false? (42)

true

When this non-boolean value is coerced to a boolean, does it become true or false? (function foo() { .. } (functions))

false

When this non-boolean value is coerced to a boolean, does it become true or false? (null, undefined)

true

When this non-boolean value is coerced to a boolean, does it become true or false? (true)

true

When this non-boolean value is coerced to a boolean, does it become true or false? ({ }, { a: 42 } (objects))

scope

When you declare a variable, it is available anywhere in that _______, as well as any lower/inner _______s.

Hoisting

Wherever a var appears inside a scope, that declaration is taken to belong to the entire scope and accessible everywhere throughout. This is known as _________.

for loop

While a while (or do..while) can accomplish looping the task manually, there's another syntactic form called a ___________ (which is the recommended way to write a loop)

implicit binding

With __________ as we just saw, we had to mutate the object in question to include a reference on itself to the function, and use this property function reference to indirectly (implicitly) bind this to the object.

fall through

Within a switch statement we omit the break resulting in "__________" and is sometimes useful/desired:

break

Within a switch statement, If you omit ______ from a case, and that case matches or runs, execution will continue with the next case's statements regardless of that case matching.

the values

You can also iterate over ___________ in data structures (arrays, objects, etc) using the ES6 for..of syntax, which looks for either a built-in or custom @@iterator object consisting of a next() method to advance through the data values one at a time.

else clause

You can even provide an alternative if the condition isn't true, called an _________.

individual function

You can opt in to strict mode for an _____________:

entire file

You can opt in to strict mode for an _______________.

remember

You can think of closure as a way to "__________" and continue to access a function's scope (its variables) even once the function has finished running.

slower

Your code will almost certainly tend to run _________ simply by the fact that you include an eval(..) or with anywhere in the code.

undefined

____ is the output. Not 2, nor a ReferenceError.

this

_____ is neither a reference to the function itself, nor is it a reference to the function's lexical scope.

this

______ is actually a binding that is made when a function is invoked, and what it references is determined entirely by the call-site where the function is called.

bar()

______ still has a reference to that scope, and that reference is called closure.

explicit

_______ coercion is simply that you can see obviously from the code that a conversion from one type to another will occur

implicit

_______ coercion is when the type conversion can happen as more of a non-obvious side effect of some other operation.

eval(..)

_______ is usually used to execute dynamically created code, as dynamically evaluating essentially static code from a string literal would provide no real benefit to just authoring the code directly.

scope look-up

________ stops once it finds the first match.

eval(..)

________ when used in a strict-mode program operates in its own lexical scope, which means declarations made inside of the eval() do not actually modify the enclosing scope.

functions

_________ are a subtype of objects -- typeof returns "function", which implies that a function is a main type -- and can thus have properties

export

_________ exports an identifier (variable, function) to the public API for the current module.

module

_________ imports an entire module API to a bound variable

import

_________ imports one or more members from a module's API into the current scope, each to a bound variable.

closure

_________ is when a function is able to remember and access its lexical scope even when that function is executing outside its lexical scope.

constants

_________, when you declare a variable with a value and intend for that value to not change throughout the program.

Object.freeze(..)

__________ creates a frozen object, which means it takes an existing object and essentially calls Object.seal(..) on it, but it also marks all "data accessor" properties as writable:false, so that their values cannot be changed.

parsing

__________ taking a stream (array) of tokens and turning it into a tree of nested elements, which collectively represent the grammatical structure of the program.

Object.seal(..)

___________ creates a "sealed" object, which means it takes an existing object and essentially calls Object.preventExtensions(..) on it, but also marks all its existing properties as configurable:false.

code-generation

___________ the process of taking an AST and turning it into executable code. (Note: The details of how the engine manages system resources are deeper than we will dig, so we'll just take it for granted that the engine is able to create and store variables as needed.)

simple primitives

____________- (string, number, boolean, null, and undefined) are not themselves 'objects'.

Inline function expressions

______________________ are powerful and useful -- the question of anonymous vs. named doesn't detract from that. Providing a name for your function expression quite effectively addresses all these draw-backs, but has no tangible downsides. The best practice is to always name your function expressions:

tokens

breaking up a string of characters into meaningful (to the language) chunks, called ________. For instance, consider the program: var a = 2;. This program would likely be broken up into the following tokens: var, a, =, 2, and ;.

constructor call

built-in object functions can be called with 'new' in front of it, and that makes that function call a __________.

lexical scope

cheating ___________ leads to poorer performance.

new

constructors are just functions that happen to be called with the _____ operator in front of them.

will not

declarations made with 'let' _______ hoist to the entire scope of the block they appear in. Such declarations will not observably "exist" in the block until the declaration statement.

Babel, Traceur

few great transpilers: ______ (https://babeljs.io) (formerly 6to5): Transpiles ES6+ into ES5 ______ (https://github.com/google/traceur-compiler): Transpiles ES6, ES7, and beyond into ES5

function declaration

function declaration or function expression:

function expression

function declaration or function expression:

lexicographically

if both values in the < comparison are strings, as it is with b < c, the comparison is made ______________ (aka alphabetically like a dictionary).

implicitly

if you use the == loose equals operator to make the comparison "99.99" == 99.99, JavaScript will convert the left-hand side "99.99" to its number equivalent 99.99. Was implicitly or explicitly coerced?

runtime

lexical scope is write-time, whereas dynamic scope (and this!) are _________.

true, false

simple rules for using == or ===: If either value (aka side) in a comparison could be the ________ or _________ value, avoid == and use ===.

(0, "", or [] -- empty array)

simple rules for using == or ===: If either value in a comparison could be of these specific values _____________, avoid == and use ===.

==

simple rules for using == or ===: In all other cases, you're safe to use _______. Not only is it safe, but in many cases it simplifies your code in a way that improves readability.

objects

take special note of the == and === comparison rules if you're comparing two non-primitive values, like _________ (including function and array). Because those values are actually held by reference, both == and === comparisons will simply check whether the references match, not anything about the underlying values.

"object"

typeof null is an interesting case, because it errantly returns __________, when you'd expect it to return "null". (Warning: This is a long-standing bug in JS, but one that is likely never going to be fixed. Too much code on the Web relies on the bug and thus fixing it would cause a lot more bugs!)


Kaugnay na mga set ng pag-aaral

The crusades discovery education

View Set

Chapter 30: Nursing Management: Diabetes Mellitus

View Set

California Real Estate Principles Unit 7: Contracts

View Set

Chapter 21 - Anaphylactic Reactions

View Set

Chemistry Test 1- Final Exam Study Guide

View Set

The History test study guide 10-11

View Set