Global function is not working javascript window object -


नीचे कुछ जावास्क्रिप्ट कोड है:

  showFullName (); // पीटर अलाली window.showFullName (); // पीटर एली  

इन दो फ़ंक्शन कॉल्स केवल विंडो ऑब्जेक्ट पर हैं लेकिन पहली कॉल ठीक काम करती है, लेकिन दूसरा एक नीचे त्रुटि देता है:

TypeError: अनिर्धारित एक समारोह नहीं है

  var firstName = "Peter", lastName = "सहयोगी"; फ़ंक्शन showFullName () {console.log (this.firstName + "+ + this.lastName); } Var person = {firstName: "पेनेलोप", अंतिमनाम: "बैरीमोर", शोफ्लोनाम: फ़ंक्शन () {console.log (this.firstName + "+ this.lastName); }}; ShowFullName (); // पीटर अलाली window.showFullName (); // इसे आउटपुट होना चाहिए: पीटर एली, लेकिन त्रुटि देने वाला व्यक्ति। ShowFullName (); // पेनेलोप बैरीमोर  

  showFullName (); // पीटर अलाली window.showFullName (); // पीटर एली  

ये दो फ़ंक्शन कॉल्स विंडो ऑब्जेक्ट पर हैं

नहीं, केवल दूसरा वाला है पहले एक आपके स्थानीय क्षेत्र में है।

लेकिन पहली कॉल ठीक काम करती है, लेकिन दूसरा एक त्रुटि देता है

इसका अर्थ है कि कोई नहीं < कोड> showFullName विधि विंडो पर। आपने HTML कोड के वैश्विक दायरे में अपना कोड निष्पादित नहीं किया, लेकिन स्थानीय स्कोप फ़ंक्शन का घोषित किया। जो कुछ भी है, वह है।


Comments

Popular posts from this blog

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -

jquery - How to make a wrapper function in javascript? -

sql - PostgreSQL automatically update row at specific date -