`
pstinghua
  • 浏览: 24097 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Primitive Types and Reference Types

阅读更多
Numbers and booleans are primitive types in JavaScriptprimitive because they consist of nothing more than a small, fixed number of bytes that are easily manipulated at the low levels of the JavaScript interpreter. Objects, on the other hand, are
reference types. Arrays and functions, which are specialized types of objects, are therefore also reference
types. These datatypes can contain arbitrary numbers of properties or elements, so they cannot be manipulated as easily as fixed-size primitive values can. Since object and array values can become quite
large, it doesn't make sense to manipulate these types by value, because this could involve the inefficient
copying and comparing of large amounts of memory.
What about strings? A string can have an arbitrary length, so it would seem that strings should be
reference types. In fact, though, they are usually considered primitive types in JavaScript simply because
they are not objects. Strings don't actually fit into the primitive-versus-reference type dichotomy.

JavaScript strings are (presumably) copied and passed by reference, they are compared by value.

Numbers, boolean values, and the null and undefined types are primitive. Objects,
arrays, and functions are reference types.
分享到:
评论

相关推荐

    Java - A Beginner’s Guide - Sixth Edition - Herbert Schildt

    This chapter delves into the data types available in Java, including primitive types (such as `int`, `float`, and `char`) and reference types (such as `String` and `Object`). It also covers operators ...

    AW - Essential C# 4.0, 3rd Edition Mar 2010+完美版

    C# primitive data types, value and reference types, implicitly typed variables, anonymous types, plus dynamic typing in C# 4.0 Methods and parameters–including extension methods, partial meth­...

    Java Fundamentals.ppt

    Java 中有两种基本数据类型:primitive types 和 reference types。primitive types 包括整数、浮点数、字符、布尔值等,而 reference types 则包括类和接口。primitive types 的值是存储在栈中的,而 reference ...

    Metal.编程向导英文版.and.Reference.via.Swift.pdf.zip

    Metal Primitive Types 113 Responding to MTKViewDelegate Methods 115 Retrieving a Drawable 115 Creating a Command Buffer 116 Creating a Command Encoder 117 Fixed-Function State on the Command ...

    Essential C# 4.0 (第三版)

    C# primitive data types, value and reference types, implicitly typed variables, anonymous types, plus dynamic typing in C# 4.0 Methods and parameters–including extension methods, partial meth­ods, ...

    The Principles of Object-Oriented JavaScript 1st Edition

    –The difference between primitive and reference values –What makes JavaScript functions so unique –The various ways to create objects –How to define your own constructors –How to work with and ...

    jna-4.2.2 官方原版下载

    Java array and NIO Buffer arguments (primitive types and pointers) as pointer-to-buffer Nested structures and arrays Wide (wchar_t-based) strings Native long support (32- or 64-bit as appropriate)...

    java-jls8.pdf

    在类型、值和变量(Types, Values, and Variables)章节中,文档详细解释了Java类型系统的基础,包括各种类型和值的种类,其中既有基本类型(Primitive Types)也有引用类型(Reference Types),以及变量的定义和...

    Java Methods-Data Types, Variables, and Arithmetic.ppt

    Java有两大类数据类型:**原始数据类型(Primitive Data Types)**和**引用数据类型(Reference Data Types)**。原始数据类型包括: 1. **整型**(Integers):如`byte`, `short`, `int`, `long`,分别表示8位、16...

    CLR via C# 第4版 英文PDF

    CHAPTER 5 Primitive, Reference, and Value Types 111 CHAPTER 6 Type and Member Basics 151 CHAPTER 7 Constants and fields 175 chaPTer 8 Methods 181 chaPTer 9 Parameters 209 CHAPTER 10 Properties 227 ...

    Addison.Wesley.The.Java.Programming.Language.4th.Edition.Aug.2005.chm

    Chapter 8Primitives as Typesexplores the relationship between the primitive types and objects of their corresponding wrapper classes, and how boxing and unboxing can transparently convert between ...

    OpenGL ES 3.0 Programming Guide, 2nd Edition

    The reference cards contain a complete list of all of the functions in OpenGL ES 3.0 along with all of the types, operators, qualifiers, built-ins, and functions in the OpenGL ES Shading Language. ...

    课程 Java程序设计 3 - Identifier Keywords Types (怀旧版)

    Java中共有八种原始类型(Primitive Types),它们包括: 1. 整数类型:byte(1字节)、short(2字节)、int(4字节)和long(8字节)。 2. 浮点类型:float(4字节)和double(8字节)。 3. 字符类型:char(2字节...

    bootcamp-types-and-syntax-day-2:训练营类型和语法第2天

    它主要有两种数据类型:基本类型(Primitive Types)和引用类型(Reference Types)。基本类型包括字符串(String)、数字(Number)、布尔值(Boolean)、空值(null)、未定义(undefined)以及在ES6中新增的符号...

    Addison.Wesley.C++.by.Dissection.2002.pdf

    - **Simple Types:** Explains primitive data types such as integers, floats, and characters. - **Initialization:** Describes different methods of initializing variables. - **The Traditional Conversions...

    Javascript.Object.Oriented.Programming.pdf

    Chapter 19: Primitive Data Types, Arrays, Loops, And Conditions Chapter 20: Functions Chapter 21: Objects Chapter 22: Prototype Chapter 23: Inheritance Chapter 24: The Browser Environment Chapter 25: ...

    java程序设计课件

    基本数据类型(primitive types):由程序设计语言系统所定义的,不可再划分;内存大小固定,存放数据本身;与软硬件环境无关。 引用类型(reference types):在内存中存放的是指向该数据的地址,不是数据本身;...

Global site tag (gtag.js) - Google Analytics