Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

readme.md

title logoImg theme highlightTheme
Logging JavaScript Datatypes
night
Monokai
<style> </style>

Excercise 1: Logging Primitive Types

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


Logging Datatypes

This section is still in progress...

Learning Objectives

  1. Identify primitive types and non-primitive objects with console
  2. Explain the null bug and how to check for it.
  3. Demonstrate conditional logic by creating JS functions