Wednesday, June 24, 2026

React concepts/Javascript

1. Named Exports


 A named export in JavaScript and TypeScript allows you to export multiple variables, functions, or classes from a single file. Unlike default exports, which only allow one primary value per module, named exports are ideal for sharing utility functions and keeping your codebase highly modular.

How to use Named Exports
1. Inline Exporting
You can export variables or functions directly as you declare them:-
// mathUtils.js
export const add = (a, b) => a + b;
export const subtract = (a, b) => a - b;
export const PI = 3.14159;
2. Exporting at the Bottom
Alternatively, you can declare your items first and export them together at the bottom of the file:-
// mathUtils.js
const multiply = (a, b) => a * b;
const divide = (a, b) => a / b;

export { multiply, divide };
How to Import Named Exports
When importing named exports, you must wrap the exact names in curly braces {}.
// app.js
import { add, PI } from './mathUtils.js';

console.log(add(2, 3)); // 5
console.log(PI);       // 3.14159
Useful Tricks
  • Renaming: You can use the as keyword to rename an export if it conflicts with an existing variable in your file:-
    import { add as sum } from './mathUtils.js';

  • Importing Everything: You can import all exported members at once into a single object using * as:
  • import * as math from './mathUtils.js';
    console.log(math.add(2, 3));

    We can export components using export default or named exports and import them using "Import"
    In one file only one default export can be there and no limit on named export components.
    componentName.js
    export default componentName;
    import ComponentName from componentName;
2.

Monday, May 25, 2026

Javascript Coercion

 

JavaScript == Type Coercion Table

ExpressionResultWhy?
0 == falsetruefalse is coerced to 0
0 == ""true"" is coerced to 0
"" == falsetrueBoth become 0
"0" == falsetrue"0"0, false0
null == undefinedtrueSpecial rule in JS spec
null == 0falseNo coercion between null and numbers
undefined == 0falseNo coercion between undefined and numbers
"5" == 5true"5"5
true == 1truetrue1
true == 2falsetrue1, 1 != 2
[] == ""true[]""
[] == 0true[]""0
[""] == 0true[""]""0
[1] == 1true[1]"1"1
[] == falsetrue[]""0, false0
[null] == 0true[null]""0
["0"] == falsetrue"0"0, false0

Key Takeaways

  • == can be confusing because it tries to convert values to a common type.
  • null and undefined are only loosely equal to each other, not to anything else.
  • Arrays and objects are converted to primitives before comparison.
  • Always prefer === unless you really want these coercion rules.

Sunday, March 15, 2026

Sree Suryastakam

 श्री सूर्य अष्टकम 

आदिदेव नमस्तुभ्यं प्रसीद मम भास्कर ।
दिवाकर नमस्तुभ्यं प्रभाकर नमोSस्तु ते ॥1॥

सप्ताश्वरथमारूढं प्रचण्डं कश्यपात्मजम् ।
श्वेतपद्मधरं देवं तं सूर्यं प्रणमाम्यहम् ॥2॥

लोहितं रथमारूढं सर्वलोकपितामहम् ।
महापापहरं देवं तं सूर्यं प्रणमाम्यहम् ॥3॥

त्रैगुण्यं च महाशूरं ब्रह्मविष्णुमहेश्वरम् ।
महापापहरं देवं तं सूर्यं प्रणमाम्यहम् ॥4॥

बृंहितं तेज:पु़ञ्जं च वायुमाकाशमेव च ।
प्रभुं च सर्वलोकानां तं सूर्यं प्रणमाम्यहम् ॥5॥

बन्धूकपुष्पसंकाशं हारकुण्डलभूषितम् ।
एकचक्रधरं देवं तं सूर्यं प्रणमाम्यहम् ॥6॥

तं सूर्यं जगत्कर्तारं महातेज:प्रदीपनम् ।
महापापहरं देवं तं सूर्यं प्रणमाम्यहम् ॥7॥

तं सूर्यं जगतां नाथं ज्ञानविज्ञानमोक्षदम् ।
महापापहरं देवं तं सूर्यं प्रणमाम्यहम् ॥8॥

इति श्रीशिवप्रोक्तं सूर्याष्टकं सम्पूर्णम् ।

सूर्याष्टकं पठेन्नित्यं ग्रहपीडा प्रणाशनम् ।
अपुत्रो लभते पुत्रं दारिद्रो धनवान् भवेत् ॥

अमिषं मधुपानं च यः करोति रवेर्दिने ।
सप्तजन्मभवेत् रोगि जन्मजन्म दरिद्रता ॥

स्त्री-तैल-मधु-मांसानि ये त्यजन्ति रवेर्दिने ।
न व्याधि शोक दारिद्र्यं सूर्य लोकं च गच्छति ॥



Om Hraam Hreem Hraum Sah Suryay Namah
Om Ghrini Suryaya Namaha/