Wednesday, 1 April 2015

Javascript Interview Questions and Answers for Experienced

Javascript Interview Questions and Answers for Experienced


Question: What is JavaScript closures? Give an Example?
A closure is an inner function that has access to the outer function's variables known as Closure.
 function function1(x) {
  var tmp = 3;
  function function2(y) {
    console.log(x + y + (++tmp)); // will console 7
  }
  function2(1);
}

function1(2);


Question: What is the function of the var keyword in Javascript?
var is used to create the local variables.
If you're in a function then var will create a local variable.
 var x =10;
function function1(){
var x=20;
}
function1();
alert(x); //10 

var x = 10 declares variable x in current scope.
If the declaration appears in a function It is a local variable.
if it's in global scope - a global variable is declared.
 
x =10;
function function1(){
x=20;
}
function1();
alert(x); //20
x=10 declare a global variable.


Question: How can I make a redirect page using jQuery?
 window.location.href = "http://www.web-technology-experts-notes.in/p/sitemap.html";


Question: How can I check if one string contains another substring?
you can use indexOf function,
If string found - It will returns the position of the string in the full string.
If string not found- it will return -1
See Example
 
var haystack = "full-string-here";
var needle = 'string';
if(haystack.indexOf(needle)>=0){
    console.log('String found');
}else{
console.log('String Not found');
}


Question: What is difference between == and === in javascript?
Both are used to check the equality only difference === check with both data type.
For Example
 2=='2' // will return true;
2==='2'// will return false;


Question: Can I comment a JSON file?
No, but you can add a node on root where you can display the information.


Question: How to Check checkbox checked property?
 var checkboxStatus = $('#checkMeOut').prop('checked'); 
if(checkboxStatus){
    console.log('Checkbox is Checked');
}else{
    console.log('Checkbox is Not Checked');
}


Question: How to include a JavaScript file in another JavaScript file?
With use of jQuery, its quite simple, See below:
 $.getScript("my_lovely_script.js", function(){   

});


Question: How to remove single property from a JavaScript object?
var myobject=['Web','Technology','Experts','Notes']
delete myobject['Technology'];


Question: How to add single property from a JavaScript array?
var myobject=['Web','Technology','Experts','Notes']
 myobject.push(' Web Development');


Question: How to empty an array?
var myobject=['Web','Technology','Experts','Notes']
 myobject.length = 0


Question: How to trim string in JavaScript?
You can do in very simple way using jQuery.
See Below:
$.trim('  Web Technology   ');


Question: How do you get a timestamp in JavaScript?
new Date().getTime()


Question: How to use javaScript Loop?
var myobject=['Web','Technology','Experts','Notes']
for (index = 0; index < myobject.length; ++index) {
    console.log(myobject[index]);
}


Question: How to detect an undefined object property in JavaScript?
if (typeof myobject === "undefined") {
    console.log("myobject is undefined");
}


Question: How to validate email address in JavaScript?
function validateEmail(email) {
    var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    return re.test(email);
}
validateEmail('contactuse@web-technology-experts-notes.in'); // Will return true;


Question: How to capitalize the first letter of string?
function capitalizeFirstLetterOfString(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}
capitalizeFirstLetterOfString('web-technology-experts-notes'); //Web-technology-experts-notes


Question: How to get current url in web browser?
window.location.href


Question: How can I refresh a page with jQuery?
window.location.reload();



Tuesday, 31 March 2015

Paypal Integration Interview Questions and Answers

Paypal Integration Interview Questions and Answers
PayPal is an Online Payments System
Online money transfers serve as electronic alternatives to traditional paper methods like checks and money orders. 
PayPal is one of the world's largest internet payment companies.
From: Wikipedia 



Question: When Paypal was founded?
June 1998


Question: Who is CEO of Paypal?
Dan Schulman


Question: What is offical website of Paypal?
www.paypal.com


Question: In which language paypal is written?
C++, JavaScript


Question: What is PayPal Sandbox?
PayPal sandbox is a testing environment of paypal.com. Developer first create account in Sandbox(https://developer.paypal.com/) and integrate the payment with sandbox. After completing all (including testing), then update the API keys.


Question: What is recurring payment?
When Customer pay fixed amount on a regular basis to the merchant is know as recurring payment. For Example: You buy a home and pay some amount on regular basis to bank for x months.


Question: What is Website Payments Standard?
Accept online payments from customers with with OR without PayPal accounts.
In this website, accept credit/debit cards (Visa, MasterCard, American Express and Discover), eChecks, bank transfers, and PayPal accounts.


Question: Is it compulsary to create paypal account for customer, when doing payment with paypal.com?
No, Customer can pay with credit/debit card on paypal.com. He have option to paypal account.


Question: Does paypal support mulitple language?
Yes.


Question: Can we customize the checkout page on paypal.com as per requirement?
Yes, You can customize the logo, item detail and description etc by passing some optional parameter.


Question: What is Paypal Pro Account?
When you want customer must do payment on your website (customer never leave website OR Never redirect to paypal.com) with credit card/debit card.



Question: Can I create payment buttons using an paypal API?
Yes


Question: Does paypal support payment by Mobile?
Yes, https://developer.paypal.com/webapps/developer/docs/classic/products/#mobile


Question: What is PayPal Express Checkout?
PayPal Express Checkout is a powerful API-based solution that can be integrated into any merchant website. With PayPal Express Checkout API, customer leave the merchant website and complete the transaction in paypal.com, where customer can pay with paypal.com OR with credit card / Debit card. When start processing, Paypal gives a TOKEN key which is used to charge money from customer OR get the Payment Details OR Customer Shipping/Billing details. Developer should save this token key for future use. Read More


Question: What is Paypal Adaptive Payment?
Paypal Adaptive Payments is feature of Paypal Pro means you must have Paypal pro account for use this payment method. In this customer can pay with Credit Card/Debit Card/Paypal.com account. While paying with Credit card/Debit card he can also create a account in paypal.com. Adaptive payments handles payments between a sender and one or more receivers. Read more


Question: What are two different types of Adaptive Payment?
  • Adaptive Parallel Payment
  • Adaptive Chain Payment



Question: What is Do-Direct Payment?
Direct Payment lets buyers pay using their credit cards and amount is directly transferred to merchant account.


Question: What is MayPay Payment?
Merchant can send the money to two or more personal in single transaction.


Question: How to create paypal buy now button on paypa.com?
http://www.web-technology-experts-notes.in/2013/02/paypal-buy-now-button.html


Question: What is notify URL in PayPal?
When we send our customer to paypal.com for payment. We send notify_url=http://www.mysite.com/notify_url.php along with price and item detail.
After completing the process PayPal returns data back to our site via what they call IPN (Data is send to the notify_url with post method). Now we save this all data in our database for further inquiry.


Question: What is paypal cancel url?
An mywebsite URL where the user will be returned if payment is cancelled by customer on paypal.com.
Cancel URL send as below:
CANCELURL=http://www.mysite.com/cancel_url.php


Question: Do website need SSL for accepting payments?
Yes, you must have SSL Integration in website.


Question: What are basic information which you must pass to the paypal for every transaction.
Following are different parameter which we must pass.
  • USER
  • PWD
  • SIGNATURE
  • VERSION
  • METHOD
  • PAYMENTACTION



Question: How to add button to get payments?
https://www.paypal.com/cgi-bin/webscr?cmd=_wp-standard-integration-outside#sectiona


Question: From where I can create Sandbox Account?
https://developer.paypal.com/