How can I differentiate between an object literal other Javascript objects?
问题 Update : I'm rephrasing this question, because the important point to me is identifying the object literal: How can I tell the difference between an object literal and any other Javascript object (e.g. a DOM node, a Date object, etc.)? How can I write this function: function f(x) { if (typeof x === 'object literal') console.log('Object literal!'); else console.log('Something else!'); } So that it only prints Object literal! as a result of the first call below: f({name: 'Tom'}); f(function() {