Skip to main content


Showing posts from May, 2018

Remove www & force https from URL using htaccess

By Using below code we are able to remove www and force https from URL using htacces   RewriteEngine On   RewriteCond %{HTTP_HOST} ^$ [NC] RewriteRule ^(.*)$$1 [R=301,L]   RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]   Or   <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] </IfModule>

Split a string and get last match in jQuery and Javascript

Method 1: str = "~test content ~thanks ok";    strFine =str.substring(str.lastIndexOf('~')); console.log(strFine ); Output: Method 2: str = "~test content ~thanks ok";    console.log(str.split('~').pop()); OR str = "~test content ~thanks ok";  var parts = str.split("~"); var what_you_want = parts.pop(); Output: Method 3: str = "~test content ~thanks ok";    arr = str.split('~'); strFile = arr[arr.length-1]; console.log(strFile ); Output:

AngularJS interview questions - Part 3

Q21. What is Angular Expression? Ans: Angular expressions are JavaScript-like code snippets that are usually placed in bindings such as {{ expression }} . For example, these are valid expressions in Angular: {{ 3+4 }} {{ a+b }} {{ }} {{ items[index] }} Demo Q22. How Angular expressions are different from JavaScript expressions? Ans: Angular expressions are like JavaScript expressions but there are few differences.   Context : In Angular, the expressions are evaluated against a scope object, while the JavaScript expressions are evaluated against the global window object. Forgiving: In Angular expression evaluation is forgiving to null and undefined, while in JavaScript undefined properties generates TypeError or ReferenceError. No Control Flow Statements: Loops, conditionals or exceptions cannot be used in an Angular expression. No Comma And Void Operators: You cannot use , (comma) or void in an Angular exp