how to count repeated characters in a string javascript
let str = "sanjay";
let obj = {};
for(let i=0;i<str.length;i++){ let key = str[i]; if(obj[key]){ obj[key]++ }else{ obj[key] = 1 } }
console.log(obj)
seen from Türkiye
seen from Bangladesh
seen from China
seen from United States
seen from China

seen from Russia
seen from United States
seen from China
seen from Türkiye
seen from China
seen from Türkiye

seen from China
seen from Türkiye
seen from Germany

seen from Pakistan
seen from United Kingdom
seen from Türkiye

seen from Pakistan
seen from Lithuania
seen from China
how to count repeated characters in a string javascript
let str = "sanjay";
let obj = {};
for(let i=0;i<str.length;i++){ let key = str[i]; if(obj[key]){ obj[key]++ }else{ obj[key] = 1 } }
console.log(obj)
لماذا يتم تضمين "use strict" في كود جافاسكربت؟
لفترة طويلة ، تطورت JavaScript دون مشاكل التوافق. تمت إضافة ميزات جديدة إلى اللغة بينما لم تتغير الوظائف القديمة. ولكن الجانب السلبي هو أن أي خطأ أو قرار غير كامل يؤدي إلى توقف بالكامل. كان هذا هو الحال حتى عام 2009 عندما ظهرت ECMAScript 5 (ES5). أضاف ميزات جديدة إلى اللغة وقام بتعديل بعض الميزات الموجودة. للحفاظ على عمل الكود القديم ، يتم إيقاف تشغيل معظم هذه التعديلات افتراضيًا. و تحتاج إلى تمكينها صراحةً بتوجيه خاص: "use strict".
فوائد "use strict"
إلتقاط الأخطاء الشائعة و الأخطاء الصامتة.
لا تسمح بالمتغيرات العامة Global Variables في حالة عدم وجود الكلمة المفتاحية var امام أي متغير فأنها تعتبر خطأ.
منع حذف الخصائص او Properties الغير قابلة للحذف
بالمختصر المفيد "use strict" تساعدك في كتابة كود جافاسكربت آمن و خال من الأخطاء.
We live in a society that is running on rules or the laws as we call them. They are important for the smooth functioning of the society. In the same way, some rules have been made for the developers to follow. They are called coding standards. Let’s find out their necessity and use.
We live in a society that is running on rules or the laws as we call them. They are important for the smooth functioning of the society. In the same way, some rules have been made for the developers to follow. They are called coding standards. Let’s find out their necessity and use.