在Firefox Developer Edition(OSX上的44.0a2(2015-11-14))中,如果我在控制台中console.log
一个对象,它看起来像这样:
Object { firstName: "John", lastName: "Doe", language: "en" }
有没有办法让Firefox javascript控制台显示Object的类型而不仅仅是'Object'? Chrome开发者工具具有此功能并显示:
G…r.init {firstName: "John", lastName: "Doe", language: "en"}
代码:
(function(global, $) {
var Greetr = function(firstName, lastName, language) {
return new Greetr.init(firstName, lastName, language);
}
Greetr.prototype = {};
Greetr.init = function(firstName, lastName, language) {
var self = this;
self.firstName = firstName || '';
self.lastName = lastName || '';
self.language = language || 'en';
}
Greetr.init.prototype = Greetr.prototype;
global.Greetr = global.G$ = Greetr;
}(window, jQuery));
var g = G$('John', 'Doe');
console.log(g);