Primitive - MDN Web Docs Glossary: Definitions of ... - Mozilla
文章推薦指數: 80 %
In JavaScript, a primitive (primitive value, primitive data type) is data that is not an object and has no methods. There are 7 primitive ... SkiptomaincontentSkiptosearchSkiptoselectlanguageMDNWebDocsGlossary:DefinitionsofWeb-relatedtermsPrimitiveChangelanguageExamplePrimitivewrapperobjectsinJavaScriptSeealsoPrimitiveInJavaScript,aprimitive(primitivevalue,primitivedatatype)isdatathatisnotanobjectandhasnomethods.Thereare7 primitivedatatypes:string,number,bigint,boolean,undefined,symbol,and null. Mostofthetime,aprimitivevalueisrepresenteddirectlyatthelowestlevelofthelanguageimplementation. Allprimitivesareimmutable,i.e.,theycannotbealtered.Itisimportantnottoconfuseaprimitiveitselfwithavariableassignedaprimitivevalue.Thevariablemaybereassignedanewvalue,buttheexistingvaluecannotbechangedinthewaysthatobjects,arrays,andfunctionscanbealtered.ExampleThisexamplewillhelpyouunderstand thatprimitivevaluesareimmutable.JavaScript//Usingastringmethoddoesn'tmutatethestring varbar="baz"; console.log(bar);//baz bar.toUpperCase(); console.log(bar);//baz //Usinganarraymethodmutatesthearray varfoo=[]; console.log(foo);//[] foo.push("plugh"); console.log(foo);//["plugh"] //Assignmentgivestheprimitiveanew(notamutated)value bar=bar.toUpperCase();//BAZ Aprimitivecanbereplaced,butitcan'tbedirectlyaltered.PrimitivewrapperobjectsinJavaScriptExceptfornullandundefined,allprimitivevalueshaveobjectequivalentsthatwraparoundtheprimitivevalues: Stringforthestringprimitive. Numberforthenumberprimitive. BigIntforthebigintprimitive. Booleanforthebooleanprimitive. Symbolforthesymbolprimitive. Thewrapper'svalueOf()methodreturnstheprimitivevalue.Seealso JavaScriptdatatypes Primitivedatatype(Wikipedia) Glossary JavaScript string number bigint boolean null undefined symbol Foundaproblemwiththispage?EditonGitHubSourceonGitHubReportaproblemwiththiscontentonGitHubWanttofixtheproblemyourself?SeeourContributionguide.Lastmodified:Oct8,2021,byMDNcontributorsChangeyourlanguageSelectyourpreferredlanguageEnglish(US)DeutschEspañolFrançais日本語한국어Português(do Brasil)Русский中文(简体)Changelanguage
延伸文章資訊
- 1原始型別- 维基百科,自由的百科全书
在電腦科學中,原始型別(英語:Primitive type)有別於複合型別,是由程式語言提供的資料型別,作為建立基礎。根據語言及其實作,在電腦的記憶體中,原始型別可能沒有 ...
- 2primitive - Yahoo奇摩字典搜尋結果
primitive · adj. 原始的;遠古的;早期的[B];粗糙的;簡單的;未開化的 · n.[C]. 原(始)人;原始事物;純樸的人;文藝復興以前的藝術家;風格純樸如此時期的藝術家 ...
- 3primitives 的中文翻譯| 英漢字典
沒有發現關於[primitives] 的資料相似字(pydict): primitive 相似字(foldoc): primitive 相似字(moecomp): primitive 相似字(n...
- 4程序设计中的primitives是什么意思 - 百度知道
计算机图形学(特别是在opengl编程)中primitives指的是图元(如点、线、三角形、四边形等)。 已赞过 已踩过<. 你对这个回答的评价是? 评论 收起.
- 5Primitive Definition & Meaning - Merriam-Webster
The meaning of primitive is of, belonging to, or seeming to come from an early time in the very a...