IMPORTANCE OF FUNCTION:
- MODURALITY OF CODE.
- ABSTRACTION.
- CODE REUSABILITY.
- READABILITY AND MAINTAINBILITY.
- TESTING AND DEBUGGING.
MODURALITY OF CODE: Each function can be developed, tested, and debugged independently, making the overall program more organized and easier to understand.
ABSTRACTION: Instead of dealing with the entire implementation, a programmer can use a function with a clear interface, relying on its functionality without needing to understand the internal complexities.
CODE REUSABILITY: The reuse of code by encapsulating a specific functionality. Once a function is defined, it can be called multiple times from different parts of the program, reducing redundancy and promoting efficient code maintenance. Functions can be called multiple times, reducing code duplication.
READABILITY AND MAINTAINBILITY: Functions enhance code readability by providing a clear structure and isolating specific tasks. This makes it easier for programmers to understand and maintain the code, especially in larger projects where complexity can be a challenge.
TESTING AND DEBUGGING: Functions make testing and debugging much easier than large code blocks. Since functions encapsulate specific functionalities, it is easier to isolate and test individual units of code.
WHAT IS FUNCTION SCOPE: where a variable can be accessed or used within a program. It controls the visibility and lifetime of variables across different parts of the code.
1.Determines the accessibility of variables in different parts of the program.
2.Helps prevent conflicts by restricting variable usage to specific areas.
3.Improves code organization and readability.
4.Defines the lifetime of variables during program execution.
5.Main types include global scope, local (function) scope, and block scope.
GLOBAL VARIABLE: A variable that is declared outside any function or block, so it can be used anywhere in the program, both inside functions and in the main code.
EXAMPLE:
let hotel="amman";
function(){
let container="biriyani";
consoloe.log("biriyani ready");
return container;
}
LOCAL VARIABLE:
- Declared inside a block ({} curly braces) or a function. Local variables are accessible inside the block or the function only where they are declared.
- Local variables with the same name can be used in different functions or blocks. Local variables are deleted after a function is completed.
EXAMPLE:
function makeBiriyani(){
let container="biriyani";
return container;
}
let foodcontainer = makeBiriyani();
console.log("foodcontainer");
MINIMUM VIABLE PRODUCT:(TBD) A development technique in which a new product or website is developed with the minimum features required to satisfy early adopters. The primary purpose of an MVP is to quickly release a product to market with just enough features to attract early customers and gather feedback for future development.
MODEL CONTEXT PROTOCOL:(TBD) A standardized framework by Anthropic that enables AI models to connect with external tools and data sources, providing secure, scalable and real time access without custom integrations.
Top comments (0)