JavaScript Class constructor Method - W3Schools

文章推薦指數: 80 %
投票人數:10人

The constructor() method is called automatically when a class is initiated, and it has to have the exact name "constructor", in fact, if you do not have a ... Tutorials References Exercises Videos ProNEW Menu Login PaidCourses WebsiteNEW HTML CSS JAVASCRIPT SQL PYTHON PHP BOOTSTRAP HOWTO W3.CSS JAVA JQUERY C++ C# R React Kotlin    Darkmode Darkcode × Tutorials HTMLandCSS LearnHTML LearnCSS LearnRWD LearnBootstrap LearnW3.CSS LearnColors LearnIcons LearnGraphics LearnSVG LearnCanvas LearnHowTo LearnSass DataAnalytics LearnAI LearnMachineLearning LearnDataScience LearnNumPy LearnPandas LearnSciPy LearnMatplotlib LearnStatistics LearnExcel XMLTutorials LearnXML LearnXMLAJAX LearnXMLDOM LearnXMLDTD LearnXMLSchema LearnXSLT LearnXPath LearnXQuery JavaScript LearnJavaScript LearnjQuery LearnReact LearnAngularJS LearnJSON LearnAJAX LearnAppML LearnW3.JS Programming LearnPython LearnJava LearnC LearnC++ LearnC# LearnR LearnKotlin LearnGo ServerSide LearnSQL LearnMySQL LearnPHP LearnASP LearnNode.js LearnRaspberryPi LearnGit LearnAWSCloud WebBuilding CreateaWebsiteNEW WhereToStart WebTemplates WebStatistics WebCertificates WebDevelopment CodeEditor TestYourTypingSpeed PlayaCodeGame CyberSecurity Accessibility DataAnalytics LearnAI LearnMachineLearning LearnDataScience LearnNumPy LearnPandas LearnSciPy LearnMatplotlib LearnStatistics LearnExcel LearnGoogleSheets XMLTutorials LearnXML LearnXMLAJAX LearnXMLDOM LearnXMLDTD LearnXMLSchema LearnXSLT LearnXPath LearnXQuery × References HTML HTMLTagReference HTMLBrowserSupport HTMLEventReference HTMLColorReference HTMLAttributeReference HTMLCanvasReference HTMLSVGReference GoogleMapsReference CSS CSSReference CSSBrowserSupport CSSSelectorReference Bootstrap3Reference Bootstrap4Reference W3.CSSReference IconReference SassReference JavaScript JavaScriptReference HTMLDOMReference jQueryReference AngularJSReference AppMLReference W3.JSReference Programming PythonReference JavaReference ServerSide SQLReference MySQLReference PHPReference ASPReference XML XMLDOMReference XMLHttpReference XSLTReference XMLSchemaReference CharacterSets HTMLCharacterSets HTMLASCII HTMLANSI HTMLWindows-1252 HTMLISO-8859-1 HTMLSymbols HTMLUTF-8 × ExercisesandQuizzes Exercises HTMLExercises CSSExercises JavaScriptExercises SQLExercises MySQLExercises PHPExercises PythonExercises NumPyExercises PandasExercises SciPyExercises jQueryExercises JavaExercises C++Exercises C#Exercises RExercises KotlinExercises GoExercises BootstrapExercises Bootstrap4Exercises Bootstrap5Exercises GitExercises Quizzes HTMLQuiz CSSQuiz JavaScriptQuiz SQLQuiz MySQLQuiz PHPQuiz PythonQuiz NumPyQuiz PandasQuiz SciPyQuiz jQueryQuiz JavaQuiz C++Quiz C#Quiz RQuiz XMLQuiz CyberSecurityQuiz BootstrapQuiz Bootstrap4Quiz Bootstrap5Quiz AccessibilityQuiz Courses HTMLCourse CSSCourse JavaScriptCourse FrontEndCourse SQLCourse PHPCourse PythonCourse NumPyCourse PandasCourse DataAnalyticsCourse jQueryCourse JavaCourse C++Course C#Course RCourse XMLCourse CyberSecurityCourse AccessibilityCourse Certificates HTMLCertificate CSSCertificate JavaScriptCertificate FrontEndCertificate SQLCertificate PHPCertificate PythonCertificate DataScienceCertificate Bootstrap3Certificate Bootstrap4Certificate jQueryCertificate JavaCertificate C++Certificate ReactCertificate XMLCertificate × Tutorials References Exercises PaidCourses Spaces Videos Shop Pro JSReference JSbyCategory JSbyAlphabet JavaScript JSArray concat() constructor copyWithin() entries() every() fill() filter() find() findIndex() forEach() from() includes() indexOf() isArray() join() keys() length lastIndexOf() map() pop() prototype push() reduce() reduceRight() reverse() shift() slice() some() sort() splice() toString() unshift() valueOf() JSBoolean constructor prototype toString() valueOf() JSClasses constructor() extends static super JSDate constructor getDate() getDay() getFullYear() getHours() getMilliseconds() getMinutes() getMonth() getSeconds() getTime() getTimezoneOffset() getUTCDate() getUTCDay() getUTCFullYear() getUTCHours() getUTCMilliseconds() getUTCMinutes() getUTCMonth() getUTCSeconds() now() parse() prototype setDate() setFullYear() setHours() setMilliseconds() setMinutes() setMonth() setSeconds() setTime() setUTCDate() setUTCFullYear() setUTCHours() setUTCMilliseconds() setUTCMinutes() setUTCMonth() setUTCSeconds() toDateString() toISOString() toJSON() toLocaleDateString() toLocaleTimeString() toLocaleString() toString() toTimeString() toUTCString() UTC() valueOf() JSError name message JSGlobal decodeURI() decodeURIComponent() encodeURI() encodeURIComponent() escape() eval() Infinity isFinite() isNaN() NaN Number() parseFloat() parseInt() String() undefined unescape() JSJSON parse() stringify() JSMath abs() acos() acosh() asin() asinh() atan() atan2() atanh() cbrt() ceil() clz32() cos() cosh() E exp() expm1() floor() fround() LN2 LN10 log() log10() log1p() log2() LOG2E LOG10E max() min() PI pow() random() round() sign() sin() sinh() sqrt() SQRT1_2 SQRT2 tan() tanh() trunc() JSNumber constructor isFinite() isInteger() isNaN() isSafeInteger() MAX_VALUE MIN_VALUE NEGATIVE_INFINITY NaN POSITIVE_INFINITY prototype toExponential() toFixed() toLocaleString() toPrecision() toString() valueOf() JSOperators JSRegExp Modifiers: g i m Groups: [abc] [^abc] [0-9] [^0-9] (x|y) Metacharacters: . \w \W \d \D \s \S \b \B \0 \n \f \r \t \v \xxx \xdd \uxxxx Quantifiers: + * ? {X} {X,Y} {X,} $ ^ ?= ?! Properties: constructor global ignoreCase lastIndex multiline source Methods: compile() exec() test() toString() JSStatements break class const continue debugger do...while for for...in for...of function if...else let return switch throw try...catch var while JSString charAt() charCodeAt() concat() constructor endsWith() fromCharCode() includes() indexOf() lastIndexOf() length localeCompare() match() prototype repeat() replace() search() slice() split() startsWith() substr() substring() toLocaleLowerCase() toLocaleUpperCase() toLowerCase() toString() toUpperCase() trim() valueOf() Window WindowObject alert() atob() blur() btoa() clearInterval() clearTimeout() close() closed confirm() console defaultStatus document focus() frameElement frames history getComputedStyle() innerHeight innerWidth length localStorage location matchMedia() moveBy() moveTo() name navigator open() opener outerHeight outerWidth pageXOffset pageYOffset parent print() prompt() resizeBy() resizeTo() screen screenLeft screenTop screenX screenY scrollBy() scrollTo() scrollX scrollY sessionStorage self setInterval() setTimeout() status stop() top WindowConsole assert() clear() count() error() group() groupCollapsed() groupEnd() info() log() table() time() timeEnd() trace() warn() WindowHistory back() forward() go() length WindowLocation assign() hash host hostname href origin pathname port protocol reload() replace() search WindowNavigator appCodeName appName appVersion cookieEnabled geolocation javaEnabled() language onLine platform product taintEnabled() userAgent WindowScreen availHeight availWidth colorDepth height pixelDepth width HTMLDOM HTMLDocuments activeElement addEventListener() adoptNode() anchors applets baseURI body charset characterSet close() cookie createAttribute() createComment() createDocumentFragment() createElement() createEvent() createTextNode() defaultView designMode doctype documentElement documentMode documentURI domain domConfig embeds execCommand() forms getElementById() getElementsByClassName() getElementsByName() getElementsByTagName() hasFocus() head images implementation importNode() inputEncoding lastModified links normalize() normalizeDocument() open() querySelector() querySelectorAll() readyState referrer removeEventListener() renameNode() scripts strictErrorChecking title URL write() writeln() HTMLElements accessKey addEventListener() appendChild() attributes blur() childElementCount childNodes children classList className click() clientHeight clientLeft clientTop clientWidth cloneNode() closest() compareDocumentPosition() contains() contentEditable dir firstChild firstElementChild focus() getAttribute() getAttributeNode() getBoundingClientRect() getElementsByClassName() getElementsByTagName() hasAttribute() hasAttributes() hasChildNodes() id innerHTML innerText insertAdjacentElement() insertAdjacentHTML() insertAdjacentText() insertBefore() isContentEditable isDefaultNamespace() isEqualNode() isSameNode() isSupported() lang lastChild lastElementChild matches() namespaceURI nextSibling nextElementSibling nodeName nodeType nodeValue normalize() offsetHeight offsetWidth offsetLeft offsetParent offsetTop outerHTML outerText ownerDocument parentNode parentElement previousSibling previousElementSibling querySelector() querySelectorAll() remove() removeAttribute() removeAttributeNode() removeChild() removeEventListener() replaceChild() scrollHeight scrollIntoView() scrollLeft scrollTop scrollWidth setAttribute() setAttributeNode() style tabIndex tagName textContent title HTMLAttributes getNamedItem() isId item() length name removeNamedItem() setNamedItem() specified value HTMLEvents abort afterprint animationend animationiteration animationstart beforeprint beforeunload blur canplay canplaythrough change click contextmenu copy cut dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange ended error focus focusin focusout fullscreenchange fullscreenerror hashchange input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseover mouseout mouseup offline online open pagehide pageshow paste pause play playing progress ratechange resize reset scroll search seeked seeking select show stalled submit suspend timeupdate toggle touchcancel touchend touchmove touchstart transitionend unload volumechange waiting wheel altKey altKey animationName bubbles button buttons cancelable charCode clientX clientY code ctrlKey ctrlKey currentTarget data defaultPrevented deltaX deltaY deltaZ deltaMode detail elapsedTime elapsedTime eventPhase getModifierState() inputType isTrusted key keyCode location metaKey metaKey newURL oldURL pageX pageY persisted preventDefault() propertyName relatedTarget relatedTarget screenX screenY shiftKey shiftKey stopImmediatePropagation() stopPropagation() target targetTouches timeStamp touches type which which view HTMLEventObjects AnimationEvent ClipboardEvent DragEvent Event FocusEvent HashChangeEvent InputEvent KeyboardEvent MouseEvent PageTransitionEvent PopStateEvent ProgressEvent StorageEvent TouchEvent TransitionEvent UiEvent WheelEvent HTMLCollection item() length namedItem() HTMLNodeList HTMLDOMTokenList HTMLStyles alignContent alignItems alignSelf animation animationDelay animationDirection animationDuration animationFillMode animationIterationCount animationName animationTimingFunction animationPlayState background backgroundAttachment backgroundColor backgroundImage backgroundPosition backgroundRepeat backgroundClip backgroundOrigin backgroundSize backfaceVisibility border borderBottom borderBottomColor borderBottomLeftRadius borderBottomRightRadius borderBottomStyle borderBottomWidth borderCollapse borderColor borderImage borderImageOutset borderImageRepeat borderImageSlice borderImageSource borderImageWidth borderLeft borderLeftColor borderLeftStyle borderLeftWidth borderRadius borderRight borderRightColor borderRightStyle borderRightWidth borderSpacing borderStyle borderTop borderTopColor borderTopLeftRadius borderTopRightRadius borderTopStyle borderTopWidth borderWidth bottom boxShadow boxSizing captionSide caretColor clear clip color columnCount columnFill columnGap columnRule columnRuleColor columnRuleStyle columnRuleWidth columns columnSpan columnWidth counterIncrement counterReset cssFloat cursor direction display emptyCells filter flex flexBasis flexDirection flexFlow flexGrow flexShrink flexWrap font fontFamily fontSize fontStyle fontVariant fontWeight fontSizeAdjust height isolation justifyContent left letterSpacing lineHeight listStyle listStyleImage listStylePosition listStyleType margin marginBottom marginLeft marginRight marginTop maxHeight maxWidth minHeight minWidth objectFit objectPosition opacity order orphans outline outlineColor outlineOffset outlineStyle outlineWidth overflow overflowX overflowY padding paddingBottom paddingLeft paddingRight paddingTop pageBreakAfter pageBreakBefore pageBreakInside perspective perspectiveOrigin position quotes resize right scrollBehavior tableLayout tabSize textAlign textAlignLast textDecoration textDecorationColor textDecorationLine textDecorationStyle textIndent textOverflow textShadow textTransform top transform transformOrigin transformStyle transition transitionProperty transitionDuration transitionTimingFunction transitionDelay unicodeBidi userSelect verticalAlign visibility width wordBreak wordSpacing wordWrap widows zIndex WebAPIs APIConsole APIFullscreen exitFullscreen() fullscreenElement fullscreenEnabled() requestFullscreen() APIGeolocation coordinates getCurrentPosition() position APIHistory APIMediaQueryList APIStorage clear() getItem() key() length removeItem() setItem() HTMLObjects



請為這篇文章評分?