Skip to main content

Posts

Showing posts from September, 2015

Tool: Duck Piano (Online One Octave Duck Sound Piano)

The UI snapshot of Duck Piano : Click the link below to go Duck Piano . Duck Piano

JavaScript: Checking Undefined Variable

This already has an answer on Stack Overflow. It's using typeof operator. As such: if (typeof yourVariable === "undefined") { // Do fallback method. } else { // Do your default method. } Chrome Developer Console Snapshot In this test, there's an undeclared variable called rey . The Other Method On JSLint , that method above will thrown an error message. This message: Unexpected 'typeof'. Use '===' to compare directly with undefined . To fix that, simply declare the uninitialised variable with var (or let ). Then compare that variable directly with undefined using triple equal ( === ). Like so: var yourVariable; if (yourVariable === undefined) { // Do fallback method } else { // Do your default method } Snapshot from Chrome console: 👋
Monkey Raptor uses cookies for analytics, advertisements, and functionality. Privacy Policy