| title | logoImg | theme | highlightTheme |
|---|---|---|---|
Logging JavaScript Datatypes |
night |
Monokai |
Step 1: Inside 0-student_files/chp1/primitives.js type the following code {.fragment}
let vUndefined;
const vNull = null;
const vString = "some text";
const vNumber = 10;
const vBoolean = false;
const vSymbol = Symbol('foo');
const vBigInt = BigInt(9007199254740991);
function LOGprimitive(VAR){
if (typeof VAR !=="object" && VAR !=="function" && VAR !==null && VAR !==undefined)
{
return console.log("\n PRIMITIVE: ", typeof VAR, "\n Value: ",VAR);
}
return console.log("\n NOT PRIMITIVE..")
}
LOGprimitive(vUndefined)
LOGprimitive(vNull)
LOGprimitive(vString)
LOGprimitive(vNumber)
LOGprimitive(vBoolean)
LOGprimitive(vSymbol)
LOGprimitive(vBigInt)Step 2: Define what a variable for each primitate type. {.fragment .current-only data-code-focus=1-9 }
Step 2: create something a function called LOGprimitive that uses a conditional statement and the typeof operator to determine if the variable is a primitive type {.fragment .current-only data-code-focus=10-16 }
Step 3: Here we are using a conditional if statement refers to cs-h
This section is still in progress...
- Identify primitive types and non-primitive objects with console
- Explain the null bug and how to check for it.
- Demonstrate conditional logic by creating JS functions