typeof.js revision 6:5a1b0714df0e
11558Srgrimes/* 21558Srgrimes * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 31558Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41558Srgrimes * 51558Srgrimes * This code is free software; you can redistribute it and/or modify it 61558Srgrimes * under the terms of the GNU General Public License version 2 only, as 71558Srgrimes * published by the Free Software Foundation. 81558Srgrimes * 91558Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT 101558Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 111558Srgrimes * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 121558Srgrimes * version 2 for more details (a copy is included in the LICENSE file that 131558Srgrimes * accompanied this code). 141558Srgrimes * 151558Srgrimes * You should have received a copy of the GNU General Public License version 161558Srgrimes * 2 along with this work; if not, write to the Free Software Foundation, 171558Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 181558Srgrimes * 191558Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 201558Srgrimes * or visit www.oracle.com if you need additional information or have any 211558Srgrimes * questions. 221558Srgrimes */ 231558Srgrimes 241558Srgrimes/** 251558Srgrimes * Typeof test. 261558Srgrimes * 271558Srgrimes * @test 281558Srgrimes * @run 2950476Speter */ 301558Srgrimes 311558Srgrimesvar x = { a: 1, b: "string", c: [1, 2, 3], d: function() {} }; 321558Srgrimes 3379530Sruvar MyObject = function() { 341558Srgrimes this.a = 10; 351558Srgrimes} 3679754Sdd 371558Srgrimesvar y = new MyObject(); 3868960Sru 391558Srgrimesprint(typeof x); 4099501Scharnierprint(typeof x.a); 4199501Scharnierprint(typeof x.b); 4299501Scharnierprint(typeof x.c); 431558Srgrimesprint(typeof x.d); 441558Srgrimesprint(typeof x.e); 451558Srgrimesprint(typeof y); 4668640Snik 4768640Snik 4868640Snik