rhino1.7.6.testsrc.doctests.object.freeze.doctest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rhino Show documentation
Show all versions of rhino Show documentation
Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically
embedded into Java applications to provide scripting to end users.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
js> load('testsrc/doctests/util.js');
js> Object.freeze;
function freeze() { [native code for Object.freeze, arity=1] }
js> [undefined, null, true, 1, 'hello'].forEach(function(value) {
> expectTypeError(function() { Object.freeze(value) })
> })
js> expectTypeError(function() { Object.freeze() })
js> var x = {}
js> var y = Object.freeze(x)
js> x === y
true
js> var obj = Object.defineProperty({}, 'a', {configurable:true, writable:true})
js> var _ = Object.freeze(obj)
js> var a = Object.getOwnPropertyDescriptor(obj, 'a');
js> a.configurable
false
js> a.writable
false
js> Object.isExtensible(obj)
false
js> Object.isFrozen(obj)
true
js> var _ = Object.freeze([])
js> var _ = Object.freeze({})
js> var _ = Object.freeze(function(){})
js> var _ = Object.freeze(/a/)
js> var _ = Object.freeze(RegExp)
© 2015 - 2024 Weber Informatics LLC | Privacy Policy