Monday, February 5, 2024

React Native Interview Questions

1. What are the core components of React Native?

Answer:  Components are the building blocks of React Native; when combined, they make up the app as a whole. Some of the most common components are:

View : used to display the entire app layout

Text : used to display text

TextInput : used to input text

ScrollView : used to insert a scrolling container

StyleSheet : used to insert style objects

Image : used to render images

Button : used to insert buttons


2. What is the role of props in React Native?

Props provide properties to components inserted in a program, which makes components modifiable and customizable. For example, the same component might be used in different parts of an app. When we use props, we can alter the component’s appearance or behavior.


3. What is the role of Flexbox in React Native?

In React Native apps, Flexbox is used to provide a consistent layout across different screen types. 

The Flexbox algorithm helps to structure the positioning of different components and create a responsive UI for the end user.


4. What is the state in React Native?

In React Native, the state refers to information about a property at a given time. Unlike props, the state is mutable; it can change. Typically, this will occur when a user interacts with the component.

For example, if your app had a filling form that users are invited to complete, the state of that component would change when the user types something in.


5. What engine does React Native use?

In React Native, JavaScript code runs through two engines:

JavaScriptCore: is used on iOS simulators and Android emulators; virtually all operations run through this engine

V8 :  is used when Chrome debugging is being performed


6. What are the main performance issues in React Native and what causes them?

Some of the most common performance issues in React Native include:

High CPU usage: Offloading complex functions to the JavaScript thread can cause performance issues

Memory leak: Information can be lost in the Bridge during the transfer from the Primary to the React Native domains, especially in Android apps

Slow navigation: Multiple thread bridging can also cause slower navigation times


7. What is the role of hooks in React Native?
Hooks allow developers to ‘hook into’ existing components and access their state and lifestyle features. 
Previously, these would not be accessible for use elsewhere. With hooks, developers can now tap into a component’s state and lifestyle 
features without having to write a new class.

8. What is the role of fast refresh in React Native?
Fast refresh allows developers to get near-instant feedback on recent changes in their app. 
Once ‘Enable fast refresh’ in the developer menu is toggled, any new edits in the program become visible within a few seconds 
for an easy evaluation.

9. How can sensitive data be stored securely in React Native?

Most React Native data is stored in Async Storage. As an unencrypted, local form of storage, it’s not suitable for storing sensitive data such as tokens and passwords.

Alternatively, React Native Keychain offers a secure form of storage that also works similarly to Async Storage. For iOS, Keychain storage can be used to protect sensitive data, while Android developers can use Facebook Conceal and Android Keystone.

10. How are hot reloading and live reloading in React Native different? 

Live reloading in React Native refreshes the entire app when a file changes, whereas hot reloading only refreshes the files that were changed. 

When hot reloading is used on an app, the state remains the same and the developer is returned to the page they started on. The opposite is true for live reloading.


11.When would you use ScrollView over FlatList and vice versa?

ScrollView loads all data items on one screen for scrolling purposes. All the data is stored on RAM, which can cause performance issues for large amounts of data. 

FlatList only displays items that are currently shown on the screen (10 by default), thus sidestepping any performance issues.

Therefore, it is best to use FlatList for large datasets, whereas ScrollView can be used for smaller datasets.

12.Could you explain how you would eliminate value duplicates in an array?

JavaScript developers can eliminate value duplicates in an array using several methods. 
Doing so is crucial for improving the code’s performance and enhancing the user experience.

The first option they may consider is using Set, an inbuilt object that stores unique values in arrays. 
It works with the set() constructor function, which creates an instance of unique values.

Alternatively, developers might implement the filter() method to achieve the same goal. For example, 
if they want to create a new array that features unique values, they could use the following code snippet:

const arr = [1, 1, 2, 3, 3, 4];

const uniqueArray = arr.filter((value, index) => arr.indexOf(value) === index);

console.log(uniqueArray); // Output [1, 2, 3, 4]

13. Difference between “ == “ and “ === “ operators.
Both are comparison operators. The difference between both the operators is that “==” is used to compare values whereas, “ === “ is used to compare both values and types.

Example: 
var x = 2;
var y = "2";
(x == y)  // Returns true since the value of both x and y is the same
(x === y) // Returns false since the typeof x is "number" and typeof y is "string"

14. Explain what is typecasting



15. Describe the differences between null and undefined in JavaScript. When would you use one over the other?

null is an intentional absence of any object value, while undefined represents the absence of a value in a variable. Use null when you want to explicitly indicate that a variable has no value, and use undefined when a variable has been declared but not assigned a value.

16. What are the differences between arrow functions and regular functions in JavaScript? When would you choose one over the other?

Arrow functions have a shorter syntax, do not bind their own this, and do not have their own arguments object. They are often preferred for concise and simple anonymous functions, while regular functions are necessary in certain situations, such as when you need access to this or arguments.

17.What is the difference between “var” and “let” keywords in JavaScript?

The var and let keywords are both used to declare variables in JavaScript. However, there are some key differences between the two keywords.

The var keyword declares a global variable, which means that the variable can be accessed from anywhere in the code. The let keyword declares a local variable, which means that the variable can only be accessed within the block of code where it is declared.


18.What are the different data types present in JavaScript?What are the different data types present in JavaScript?

There are three major data types present in JavaScript.

Primitive
Numbers
Strings
Boolean
Composite

Objects
Functions
Arrays

Trivial
Null
Undefined

19. What is the outcome of 5+3+"9"?
The 5 and 3, in this case, behave as integers, and "0" behaves like a string. Therefore 5 + 3 equals 8. The output is 8+"9" = 89.

20.Explain different functional components in JavaScript?

The functional components in JavaScript are-

First-class functions: functions are used as first-class objects. This means they can be passed as arguments to other functions, sent back as values from other functions, assigned to variables, or can even be saved as data structures.

Nested functions: These are defined inside other functions and called every time the main function is called.

21. What is the difference between synchronous and asynchronous programming?

In synchronous programming, the program execution occurs sequentially, and each statement blocks the execution until it is completed. In asynchronous programming, multiple tasks can be executed concurrently, and the program doesn’t wait for a task to finish before moving to the next one.

Synchronous coding example:
console.log("Statement 1");
console.log("Statement 2");
console.log("Statement 3");

Asynchronous code example:

console.log("Statement 1");
setTimeout(function(){
console.log("Statement 2");
}, 2000);
console.log("Statement 3");

22. How do you handle errors in JavaScript?

Errors in JavaScript can be handled using try-catch blocks. 
The try block contains the code that may throw an error, 
and the catch block handles the error and provides an alternative execution path.

23.What is the purpose of the map() function in JavaScript?

The map() function is used to iterate over an array and apply a transformation or computation on each element. It returns a new array with the results of the transformation.

const numbers = [1,2,3,4,5];
const squaredNumbers = numbers.map(function(num){
return num * num;
})
console.log(squaredNumbers);  // Output : [1, 4, 9, 16, 25] ;

24.What is the purpose of the reduce() function in JavaScript?

The reduce() function is used to reduce an array to a single value by applying a function to each element and accumulating the result.

const numbers = [1,2,3,4,5];
const sum = numbers.reduce(function(){
return acc + num;
},0);
console.log(sum); //Output : 15

25.Write a JavaScript program to find the maximum number in an array. 

Here's a simple JavaScript program that finds the maximum number in an array:

function findMaxNumber(arr) {
  if (arr.length === 0) {
    return "Array is empty";
  }

  let maxNumber = arr[0];

  for (let i = 1; i < arr.length; i++) {
    if (arr[i] > maxNumber) {
      maxNumber = arr[i];
    }
  }

  return maxNumber;
}

// Example usage:
const numbers = [3, 7, 1, 9, 4, 6, 8];
const max = findMaxNumber(numbers);

console.log("The maximum number is:", max);

Advanced JavaScript Program to find the maximum number in an array

function findMaxNumber(arr) {
  if (arr.length === 0) {
    return "Array is empty";
  }

  return Math.max(...arr);
}

// Example usage:
const numbers = [3, 7, 1, 9, 4, 6, 8];
const max = findMaxNumber(numbers);

console.log("The maximum number is:", max);

26. Write a JavaScript program to reverse a given string. 

function reverseString(str) {
  return str.split('').reverse().join('');
}

// Example usage:
const originalString = 'Hello, World!';
const reversedString = reverseString(originalString);

console.log("Original String:", originalString);
console.log("Reversed String:", reversedString);



Other javascript coding interivew questions : https://www.keka.com/javascript-coding-interview-questions-and-answers





Write a code to eliminate value duplicates in an array?
Write a code to reverse a String?

0 comments:

Post a Comment

Labels

.htaccess (5) 2step verification in php (1) 404 Page (1) Address Autocomplete (1) Admin (1) Ajax (3) alias key generation (1) All Browsers Testing (1) Android (19) Android 5.0 (2) Android Life Cycle (1) Android webview media capture (1) angular js (7) Angular Js ebook (1) AngularJS (23) Apache and mysql start up automatically once system boot (1) array_combine() (1) array_merge() (1) array_search() (1) async css and js (1) auto generate url slug in codeginiter (1) Auto reload (1) Autocomplete (1) automation code for php and mysql (1) AWS (1) AWS EC2 Hosting (6) AWS EC2 Hosting Connect with notepad++ (1) AWS ECS Hosting (1) base_url() (1) Basic php example on this keyword use (1) Best Practices to write jquery (1) Bootstrap (2) Bootstrap form tag problem (1) Bootstrap Modal (1) Bootstrap Modals (1) Breadcrumb (1) Broad band usage meter (1) Can't connect to MySQL server on (1) Cannot retrieve metalink for repository (1) Career Guidance (1) Carousel (1) Categories of websites (1) Cent OS (2) CI (1) Ci Errors (1) ckeditor (3) Clear Browser Cache Trick (1) Client IP Address (1) Code completion for codeigniter (1) Codehint for CodeIgniter (1) CodeIgniter (54) Codeigniter Controllers (1) Codeigniter email (1) Codeigniter file upload (2) Codeigniter send grid integration (1) CodeIgniter with Dreamweaver (1) Codigniter4 (1) color replace function in jquery (1) colorReplace function (1) configuration files locations (1) Controllers in controllers angular js (1) Cookies (1) core php file upload (1) count down timer in seconds in jquery (1) Countries Table in mysql (1) Create User in mysql Db (1) CryptoJS (1) CSS (3) CSS tricks (2) curl parallel calls (1) Currency API (1) Customize date format in php (1) Data dictionary (1) data of birth validation and generation codeigniter (1) Database backup in php (1) date (1) Date Difference (2) date difference in jquery (1) Date format in php (1) Date functions (1) datepicker date format jquery (1) Datetime Picker (1) datewise mysql backup (1) DBFunctions (1) Default Image in html (1) Desktop tricks (1) Detect Android Mobile (1) Detect Iphone using javascript (1) Disadvantages of Joomla (1) Disadvantages of Wordpress (1) Distance Calculation (1) document printing (1) Document submit (1) dreamweaver (1) Drupal CMS (2) Drupal Components (1) Drupal Update (1) Dynamic jQuery (21) Dynamic websites building (1) echo (1) editor for html interface (1) Email (2) Email extract in php (1) email php configuration (1) empty() and is_null() difference (1) error handling in php (1) event.PreventDefault() (1) execution time in javascript (1) extract numbers php (1) Facebook Link Posting (1) Facebook Login Error Javascript (1) Facebook Page Likes (1) Fancybox (1) Fastpanel (1) Features of Joomla (1) Features of Wordpress (1) file upload (1) File upload in jquery (1) File upload through URL with php script (1) file_get_contents (1) Files listing from folders in php (1) FileUpload (2) fileupload in jquery with preview (1) filezilla (1) Filter to top (1) Find the Framework of a website (1) Firewall Configuration in Centos (1) FOR php developers (2) Form_validation form with codeigniter (1) FTP (1) Full calendar (1) Geo API (4) Geo Code (2) Geo complete (1) Geo Location (1) GeoLocation (4) get ipaddress (1) gmail contacts api (1) Google Chrome Install (1) Google Map (1) Google Maps (9) Grant all privileges in mysql db (1) Grocery Crud (5) Guess CMS (1) hashtag (1) History Clear (1) HMVC (1) Host is not allowed to connect to MySQL Server (1) how to include header and footer html in html (1) How to prevent sql injection in php (1) how to zip file in linux (1) HTML (4) HTML CSS JS compression (1) HTML Typography (1) HTML5 (4) httpd.conf Configurations (1) Huge IT Silder (1) Hybrid App (1) Hyperlinks (1) image resize in codeigniter (1) Image with preview and remove html (1) Include() and include_once Difference (2) India States (1) Interfaces in PHP (1) Internal server error solution (1) Invoice Templates (1) ionic (13) ionic ios (1) iOS (3) iTunes (1) Javascript (45) javascript countdown timer (1) javascript email validation (1) Javascript Object properties view (1) Javascript UNIX time stamp converter (1) jmeter (3) Jquery (40) jquery datepicker (2) jquery detect idle state (1) jquery list sort (1) Jquery OWL Carousel (1) Jquery UI (1) jquery username validation (1) jquery validation (1) JS (1) JSON (3) Laravel (4) Laravel Tutorials (2) Latest Android Version (1) Linux commands (5) LINUX Ftp Configuration (1) Linux Server IP Address (1) List Sortable in Jquery UI (1) Lollipop (1) Magento (1) mail in php (1) main controller and child controller and another child controller (1) maximum execution time in php code (1) Media Capture in HTML5 (1) method overloading in php (1) method overriding in php (1) mod_rewrite (1) Mouse Deselection Javascript (1) Multidimensinal Array sort (1) multiple comparisons in php (1) Multiple file upload in Angular JS (1) Multiple file upload in jquery (1) multiple file upload in php (1) multiselect (1) Mysql (21) mysql and apache start up automatically once system boot (1) mysql connect (1) mysql connect in windows os (1) mysql database backup (1) mysql datatypes (1) Mysql DB (1) mysql Db connection program (1) Mysql Errors (1) mysql functions (1) MySQL HostName (1) mysql query tricks (1) MySQL server at 'reading initial communication packet' (1) mysql_real_escape_string() (1) mysql_secure_installation (1) mysql.sock (2) Error (1) mysqli (2) Native App (1) Netbeans for linux (1) Network usage monitor (1) ng-bind (1) ng-click (1) Node js (1) Notepad++ (1) onchange display images (1) Online UNIX Timestamp to human readble format converter (1) OOPS in php (1) Pagination in Codeigniter (1) Pagination in php (1) Password encryption and decryption in php (1) Paypal (1) PayU Form (1) PDF (1) PDO (2) Pendrive Data Recovery (1) php (62) PHP 5.4.0 (2) php abstract class example (1) PHP ajax file upload (2) PHP ajax request detection (1) PHP Basic Login and logout (1) PHP Codeigniter database backup code (1) PHP Contact us email form code (1) PHP corn jobs (1) php database backup script (1) php email validation (1) PHP Environment Setup (1) PHP Errors (1) PHP Extension and Application Repository) (1) php file upload (1) PHP File Uploading (1) PHP fileupload helper in codeigniter (1) PHP interview questions (4) PHP lamda functions examples (1) PHP Login (1) PHP pdo (1) PHP PDO script to insert data inside mysql db (1) PHP Random Password generation Script (2) php script execution limit (1) php script to display months (1) php script to print years as dropdown (1) PHP Storm (2) PHP Storm license key (1) PHP strong encryption and decryption (1) php timeslot generator (1) php-mysql Modules (1) phpmyadmin (2) phpMyAdmin install (1) Pin-code finder (1) Pincode (1) Play youtube video in angular JS (1) Popup (2) POPUP in javascript (1) POST and GET Difference (1) POST DATA IN PHP (1) Postfix sendmail (1) preview of selected file (1) Print content with jquery (1) print() (1) Push Notifications (1) query string based pagination in codeigniter (1) Random key (1) ratings (1) regular expressions (1) remote validation (1) remove query string (1) Remove Sale Tag or Logo of woocommerce (1) Repository (1) require_once() (1) require() (1) Resize Image Dynamically (1) result_array() (1) rpmdb open fail (1) Salaries (1) SCP Command syntax (1) select images display in webbrowser (1) Selected values in javascript (1) Send free sms (1) Send Grid (1) Send Grid Email integration (1) SEO PHP (1) Session Management in PHP (1) show active class in the url automatically php (1) Show alternate image (1) simple ajax php script (1) Simple Login in PHP (1) Simple registraion (1) single file upload (1) site2sms script (1) Slideshow (1) SMTP Configuration (2) SOFTWARE TECHNOLOGY TIPS (1) Sort list items by Mouse in jquery (1) sprintf in php (1) SQL Injection in php (1) States Countries API (1) static variable in javascript (1) store date in php (1) stripslashes() (1) strtotime (1) sum of array values (1) sumo select (1) system error: 113 (1) Talk To Camera (1) Text to ASCII Generator (1) this keyword (1) Time ago function in javascript (1) Time ago Plugin (1) Time in PHP (1) time picker in grocery crud admin (1) Timeslot Generation in PHP (1) Tooltips using css (1) trigger in mysql (1) ubuntu (1) UNIX timestamp to HUMan readable converter (1) use full tutorials (1) user ur domain inseted of localhost (1) validation in javascript (1) Version Controls for PHP (1) Webmin (1) What CMS (1) Why Drupal CMS (1) Windows 10 (1) Windows Commands (1) Wordpress (2) Xampp (2) Xampp Localhost (1) Xampp Security (1) Yii Framework configuration (1) Yii framework installation (1) ZipArchive (1) ZipArchive php aws (1)
 
TOP