Skip to content

Instantly share code, notes, and snippets.

@zerovolts
Last active April 16, 2018 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerovolts/6edab7b892c5fb91259ebd18bb6ae1ca to your computer and use it in GitHub Desktop.
Save zerovolts/6edab7b892c5fb91259ebd18bb6ae1ca to your computer and use it in GitHub Desktop.

Operator: in

x in y returns true if x is a valid property of y or its prototype chain.

> "foo" in {foo: 3}
true
> 2 in ["a", "b", "c"]
true

Operator: typeof

typeof x or typeof(x) returns the type as a string.

Operator: instanceof

x instanceof y returns true if x is an object of type y.

> class A {}
> (new A) instanceof A
true

Operator: void

void x or void(x) evaluates expression x and returns undefined.

Keyword: this

Refers to the current object.

Keyword: super

Refers to the parent of the current object. Usually to call the parent constructor:

> super(props)

but also can be used to call functions on the parent:

> super.foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment