Computer >> Computer tutorials >  >> Programming >> Javascript

Difference between Procedural and Declarative Knowledge


Procedural Knowledge

Procedural or imperative knowledge clarifies how to perform a certain task. It lays down the steps to perform. For example, - how to copy an array using javascript in a procedural way.

Example

var a=[1, 2, 3, 4, 5];
var b=[];
for(var i=0;i < a.length;i++) {
   b.push(a[i]);
}
console.log(b);

Output

[1, 2, 3, 4, 5]

Declarative Knowledge

Declarative or functional knowledge clarifies what to do to perform a certain task. It lays down the function to perform. For example, - how to copy an array using javascript in a declarative way.

Example

var a=[1, 2, 3, 4, 5];
var b=a.map(function(number){
   return number*1
});
console.log(b);

Output

[1, 2, 3, 4, 5]

The following are some of the important differences between Procedural Knowledge and Declarative Knowledge.

Sr. No.KeyProcedural KnowledgeDeclarative Knowledge
1NameProcedural knowledge is also termed as imperative knowledge.Declarative knowledge is also termed as functional knowledge
2BasisProcedural knowledge revolves around How to the concept.Declarative knowledge revolves around What to the concept.
3CommunicationProcedural knowledge is difficult to communicate.Declarative knowledge is easily communicable.
4OrientationProcedural knowledge is process-oriented.Declarative knowledge is data-oriented.
5ValidationValidation is not very easy in procedural knowledge.Validation is quite easy in declarative knowledge.
6DebuggingDebugging is not very easy in procedural knowledge.Debugging is quite easy in declarative knowledge.