This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function emp() { | |
console.log('111'); | |
} | |
emp(); | |
function emp() { | |
console.log('2'); | |
} | |
Output > 2 | |
var emp = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkAnagrams(input1, input2) { | |
if(input1.length !== input2.length) { | |
return false; | |
}else { | |
var str1 = input1.toLowerCase().split('').sort().join(''); | |
var str2 = input2.toLowerCase().split('').sort().join(''); | |
if(str1 === str2) { | |
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First way | |
function swap (alphabets, index1, index2) { | |
var temp = alphabets[index1]; | |
alphabets[index1] = alphabets[index2]; | |
alphabets[index2] = temp; | |
return alphabets; | |
} | |
function permute (alphabets, startIndex, endIndex) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Both are same! | |
var obj = new Object(); //Empty Object | |
var obj = new Object; //same result | |
2. var obj = new Object(id: 1, name: "test"); | |
Output > it will give error | |
3. | |
var obj1 = {id: 1, name: "test"}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function equal(obj1, obj2) { | |
let keys = Object.keys(obj1); // first find keys of first Object | |
let output = false; | |
for (let i = 0 ; i < keys.length ; i++) { | |
output = (obj2.hasOwnProperty(keys[i]) && obj1[keys[i]] == obj2[keys[i]]) ? true : false; | |
} | |
return output; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkPalindrome(str) { | |
if(str) { | |
var pattern = /[^a-zA-z]+/g; // first remove spaces and special chars from given string | |
str = str.replace(pattern, '').toLowerCase(); | |
var str1 = str.split('').reverse().join(''); | |
console.log(str, str1); // for testing | |
if(str1 == str.toLowerCase()) { | |
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function duplicateCharCount(str) { | |
if(str) { | |
var obj = {}; | |
for(let i = 0; i < str.length; i++) { | |
if(obj[str[i]]){ | |
obj[str[i]] += obj[str[i]]; | |
}else { | |
obj[str[i]] = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="main"> | |
<div class="parent-container"> | |
<div class="row" *ngFor="let number of numberArray;let rowIndex = index;"> | |
<div [ngClass]="{'header' : rowIndex == 0 , 'input-field' : rowIndex > 0, 'first-col' : colIndex == 0 , 'highlight' : rowIndex == selectedRowIndex || colIndex == selectedColumnIndex}" | |
*ngFor="let char of charArray;let colIndex = index;"> | |
<input *ngIf="rowIndex > 0 && colIndex > 0;else headertemplate" type="text" (focus)="onInputFocus(rowIndex, colIndex)"> | |
<ng-template #headertemplate> | |
{{rowIndex == 0 ? char : number}} | |
</ng-template> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class= "main" #maindiv></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To covert the Utc time to local time | |
convertUTCDateToLocalDate(date) { | |
if (date) { | |
let date1; | |
if (date.indexOf('-') > -1) { | |
date1 = this.splitdate(date); | |
} | |
else { | |
date1 = new Date(date); | |
} |
NewerOlder