GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Notizen

Javascript Types - created from Mind Map

ashish palsingh Coding Englisch 1 Seite

Inhalt der Notizen (1)

Seite 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.

Informationen

Beschreibung
Coding Notiz am Javascript Types - created from Mind Map, erstellt von ashish palsingh am 27/03/2019.
Erstellt von
ashish palsingh
Aufrufe
1
Verlauf
  • Erstellt von ashish palsingh · 27 Mär 2019
  • Zu Notiz kopiert von ashish palsingh · 27 Mär 2019
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck