Боже мой! Я думаю, что это может быть короче, чем когда-либо, давайте посмотрим на это:
function isObject(obj)
{
return obj != null && obj.constructor.name === "Object"
}
console.log(isObject({})) // returns true
console.log(isObject([])) // returns false
console.log(isObject(null)) // returns false
Тип конструкторов и объектов JavaScript (включая null
) возвращает "object"
console.log(typeof null, typeof [], typeof {})
[1113]
Проверка их свойства constructor
возвращает функцию с их именами.
console.log(({}).constructor) // returns a function with name "Object"
console.log(([]).constructor) // returns a function with name "Array"
console.log((null).constructor) //throws an error because null does not actually have a property
Function.name
возвращает имя функции только для чтения или "anonymous"
для замыканий .
console.log(({}).constructor.name) // returns "Object"
console.log(([]).constructor.name) // returns "Array"
console.log((null).constructor.name) //throws an error because null does not actually have a property
Примечание: Начиная с 2018 года, Function.name может не работать в IE https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#Browser_compatibility
I'm not a lawyer, so take this with a grain of salt.
First off, Mozilla has nothing to do this. There is no reason to believe that Firefox add-ons are GPL-licensed by default. That's because the license of the browser doesn't affect the license of the add-ons; they don't typically reuse the browser's source code. (In fact, Firefox itself isn't necessarily GPL'd. Mozilla releases it under a tri-license which includes the Mozilla Public License as one of the license options.)
So, I'd imagine that if you don't specify a license to an add-on, then that add-on defaults to whatever copyright control would be extended to you as author of the add-on, depending on your jurisdiction.
Now if you used GPL'd code in your add-on, then that add-on would obviously be GPL-licensed if you released it publicly. Unless you got special permission from the original author to use a different license, of course.