GoConqr has a new look! Let us know what you think.

Notes

Javascript Types - created from Mind Map

ashish palsingh Coding English 1 page

Content of the notes (1)

Page 1

var a;

typeof a; // "undefined"

a = "hello world";

typeof a; // "string"

a = 42;

typeof a; // "number"

a = true;

typeof a; // "boolean"

a = null;

typeof a; // "object" -- weird, bug

a = undefined;

typeof a; // "undefined"

a = { b: "c" };

typeof a; // "object"

typeof null is an interesting case, because it errantly returns "object", when you'd expect it to return "null".

Also, note a = undefined. We're explicitly setting a to the undefined value, but that is behaviorally no different

from a variable that has no value set yet, like with the var a

The [ ] notation requires either a variable (explained next) or a string literal (which needs to be wrapped in " .. " or ' .. ').

You theoretically could use an array as a normal object with your own named properties, or you could use an object but

only give it numeric properties (0, 1, etc.) similar to an array. However, this would generally be considered improper

usage of the respective types.

arrays and function are two of subtype of object types

function foo() {

return 42;

}

foo.bar = "hello world";

typeof foo; // "function"

typeof foo(); // "number"

typeof foo.bar; // "string"

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

have properties, but you typically will only use function object properties (like foo.bar) in limited cases.

Information

Description
Coding Note on Javascript Types - created from Mind Map, created by ashish palsingh on 27/03/2019.
Created by
ashish palsingh
Views
1
History
  • Created by ashish palsingh · Mar 27, 2019
  • Copied to Note by ashish palsingh · Mar 27, 2019
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?